From fe863fe19292af898471d2ccac02d6bd92c498b5 Mon Sep 17 00:00:00 2001 From: yves Date: Tue, 14 Jul 2026 19:11:55 +0200 Subject: [PATCH] Ajout de deux codes exemples --- test-led-telecommande-anneaux.py | 55 ++++++++++++++++++++++++++++++++ test-led-telecommande.py | 40 +++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 test-led-telecommande-anneaux.py create mode 100644 test-led-telecommande.py diff --git a/test-led-telecommande-anneaux.py b/test-led-telecommande-anneaux.py new file mode 100644 index 0000000..4dbbd02 --- /dev/null +++ b/test-led-telecommande-anneaux.py @@ -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() + + diff --git a/test-led-telecommande.py b/test-led-telecommande.py new file mode 100644 index 0000000..9e8cdb6 --- /dev/null +++ b/test-led-telecommande.py @@ -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) +