From 4efb16267d2e5cee7e5e296281312aabfa0783c8 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Tue, 11 Sep 2018 17:54:01 +0200 Subject: [PATCH] Exemple tout basique avec une animation autour des couleurs --- code/main_1.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 code/main_1.py diff --git a/code/main_1.py b/code/main_1.py new file mode 100644 index 0000000..3c5df24 --- /dev/null +++ b/code/main_1.py @@ -0,0 +1,64 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Eclairage à LED Neopixel +""" +__author__ = "arofarn" +__version__ = 0.1 + +import time +import machine +import neopixel + +NB_PIX = 8 # Nombre de pixel +LUMINOSITE = 1.0 # Luminosité (0.0-1.0) +NEOPIX_PIN = 2 # N° de la broche de contrôle des néopixels + +pixel_strip = neopixel.NeoPixel(machine.Pin(NEOPIX_PIN), NB_PIX) + +#Eteint tout à l'initialisation +for i in range(NB_PIX): + pixel_strip[i] = (0, 0, 0) +pixel_strip.write() + +while True: + for i in range(NB_PIX): + print("blanc") + pixel_strip[i] = (255, 255, 255) + pixel_strip.write() + time.sleep(0.5) + + for i in range(NB_PIX): + print("éteint") + pixel_strip[i] = (0, 0, 0) + pixel_strip.write() + time.sleep(0.5) + + for i in range(NB_PIX): + print("rouge") + pixel_strip[i] = (255, 0, 0) + pixel_strip.write() + time.sleep(0.5) + + for i in range(NB_PIX): + print("vert") + pixel_strip[i] = (0, 255, 0) + pixel_strip.write() + time.sleep(0.5) + + for i in range(NB_PIX): + print("bleu") + pixel_strip[i] = (0, 0, 255) + pixel_strip.write() + time.sleep(0.5)