Ajout de deux codes exemples

This commit is contained in:
2026-07-14 19:11:55 +02:00
parent 2d6b30dd47
commit fe863fe192
2 changed files with 95 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import os, machine, time, neopixel
np = neopixel.NeoPixel(machine.Pin(15),24)
np[1] = (15, 0, 0)
np.write()
BJ = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)
BV = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP)
BB = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP)
BR = machine.Pin(2, machine.Pin.IN, machine.Pin.PULL_UP)
LR = machine.Pin(14, machine.Pin.OUT)
LV = machine.Pin(12, machine.Pin.OUT)
LB = machine.Pin(13, machine.Pin.OUT)
def raz():
LR.value(0)
LV.value(0)
LB.value(0)
#LR.value(2)
for i in range(0,24):
np[i] = (0, 15, 15)
np.write()
#np[i] = (0, 0, 0)
time.sleep(0.1)
while True:
#print(BR.value())
if BR.value() == 0:
raz()
LR.value(1)
print("R")
if BB.value() == 0:
raz()
print("B")
LB.value(1)
if BV.value() == 0:
raz()
print("V")
LV.value(1)
if BJ.value() == 0:
raz()
LR.value(1)
LV.value(1)
#for i in range(0,24):
# np[i] = (0, 255, 0)
# np.write()
+40
View File
@@ -0,0 +1,40 @@
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import os, machine, time, gc
#os.dupterm(None, 1) # disable REPL on UART(0)
BJ = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)
BV = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP)
BB = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP)
BR = machine.Pin(2, machine.Pin.IN, machine.Pin.PULL_UP)
LR = machine.Pin(14, machine.Pin.OUT)
LV = machine.Pin(12, machine.Pin.OUT)
LB = machine.Pin(13, machine.Pin.OUT)
def raz():
LR.value(0)
LV.value(0)
LB.value(0)
while True:
if BR.value() == 0:
raz()
LR.value(1)
if BB.value() == 0:
raz()
LB.value(1)
if BV.value() == 0:
raz()
LV.value(1)
if BJ.value() == 0:
raz()
LR.value(1)
LV.value(1)