Files
codes-pedagogie/test-led-telecommande-anneaux.py
T
2026-07-14 19:11:55 +02:00

56 lines
1.0 KiB
Python

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()