Boutons et relais OK
This commit is contained in:
commit
b0909e930f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
tmp/*
|
||||
3
.micropico
Normal file
3
.micropico
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"info": "This file is just used to identify a project folder."
|
||||
}
|
||||
8
.vscode/extensions.json
vendored
Normal file
8
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-python.python",
|
||||
"visualstudioexptteam.vscodeintellicode",
|
||||
"ms-python.vscode-pylance",
|
||||
"paulober.pico-w-go"
|
||||
]
|
||||
}
|
||||
15
.vscode/settings.json
vendored
Normal file
15
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"python.languageServer": "Pylance",
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"python.analysis.diagnosticSeverityOverrides": {
|
||||
"reportMissingModuleSource": "none"
|
||||
},
|
||||
"python.terminal.activateEnvironment": false,
|
||||
"micropico.openOnStart": true,
|
||||
"python.analysis.typeshedPaths": [
|
||||
"~/.micropico-stubs/included"
|
||||
],
|
||||
"python.analysis.extraPaths": [
|
||||
"~/.micropico-stubs/included"
|
||||
]
|
||||
}
|
||||
49
main.py
Normal file
49
main.py
Normal file
@ -0,0 +1,49 @@
|
||||
from machine import Pin, I2C
|
||||
import time
|
||||
|
||||
led_jaune = Pin(0, Pin.OUT)
|
||||
led_bleue = Pin(2, Pin.OUT)
|
||||
led_rouge = Pin(19, Pin.OUT)
|
||||
button_jaune = Pin(1, Pin.IN, Pin.PULL_UP)
|
||||
button_bleu = Pin(21, Pin.IN, Pin.PULL_UP)
|
||||
button_rouge = Pin(20, Pin.IN, Pin.PULL_UP)
|
||||
|
||||
i2c = I2C(scl=Pin(23), sda=Pin(22), freq=20000)
|
||||
|
||||
I2C_ADDR = 0x11
|
||||
|
||||
def button_jaune_presse(pin):
|
||||
print("Bouton jaune pressé !")
|
||||
led_jaune.on()
|
||||
led_bleue.off()
|
||||
led_rouge.off()
|
||||
set_relays(0b0011)
|
||||
|
||||
button_jaune.irq(trigger=Pin.IRQ_FALLING, handler=button_jaune_presse)
|
||||
|
||||
def button_bleu_presse(pin):
|
||||
print("Bouton bleu !")
|
||||
led_jaune.off()
|
||||
led_bleue.on()
|
||||
led_rouge.off()
|
||||
set_relays(0b1100)
|
||||
|
||||
button_bleu.irq(trigger=Pin.IRQ_FALLING, handler=button_bleu_presse)
|
||||
|
||||
def button_rouge_presse(pin):
|
||||
print("Bouton rouge pressé !")
|
||||
led_jaune.off()
|
||||
led_bleue.off()
|
||||
led_rouge.on()
|
||||
set_relays(0b1100)
|
||||
|
||||
button_rouge.irq(trigger=Pin.IRQ_FALLING, handler=button_rouge_presse)
|
||||
|
||||
|
||||
def set_relays(mask):
|
||||
"""mask = bits 0..3 (1=ON, 0=OFF)"""
|
||||
i2c.writeto_mem(I2C_ADDR, 0x10, bytes([mask]))
|
||||
|
||||
while True:
|
||||
time.sleep(1)
|
||||
|
||||
7
notes.md
Normal file
7
notes.md
Normal file
@ -0,0 +1,7 @@
|
||||
esptool --port /dev/ttyACM0 erase-flash
|
||||
|
||||
cd tmp
|
||||
wget https://micropython.org/resources/firmware/ESP32_GENERIC_C6-20250911-v1.26.1.bin
|
||||
cd -
|
||||
|
||||
esptool --port /dev/ttyACM0 --baud 460800 write-flash 0 ./tmp/ESP32_GENERIC_C6-20250911-v1.26.1.bin
|
||||
16
requirements.txt
Normal file
16
requirements.txt
Normal file
@ -0,0 +1,16 @@
|
||||
bitarray==3.8.0
|
||||
bitstring==4.3.1
|
||||
cffi==2.0.0
|
||||
click==8.3.1
|
||||
cryptography==46.0.3
|
||||
esptool==5.1.0
|
||||
intelhex==2.3.0
|
||||
markdown-it-py==4.0.0
|
||||
mdurl==0.1.2
|
||||
pycparser==2.23
|
||||
Pygments==2.19.2
|
||||
pyserial==3.5
|
||||
PyYAML==6.0.3
|
||||
reedsolo==1.7.0
|
||||
rich==14.2.0
|
||||
rich-click==1.9.4
|
||||
Loading…
Reference in New Issue
Block a user