From 3896ba5f3ec3962598ec1b3cffb78cf1e80491a5 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Mon, 10 Sep 2018 20:30:17 +0200 Subject: [PATCH] Premier test des neopixel en micropython (chenillard RGB) --- code/main.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 code/main.py diff --git a/code/main.py b/code/main.py new file mode 100644 index 0000000..0d51b5a --- /dev/null +++ b/code/main.py @@ -0,0 +1,48 @@ +# 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_NEOPIXEL = 8 # Nombre de pixel + +np = neopixel.NeoPixel(machine.Pin(2), NB_NEOPIXEL) + +while True: + for i in range(NB_NEOPIXEL): + np[i] = (255, 255, 255) + time.sleep(0.5) + np.write() + for i in range(NB_NEOPIXEL): + np[i] = (0, 0, 0) + time.sleep(0.5) + np.write() + for i in range(NB_NEOPIXEL): + np[i] = (255, 0, 0) + time.sleep(0.5) + np.write() + for i in range(NB_NEOPIXEL): + np[i] = (0, 255, 0) + time.sleep(0.5) + np.write() + for i in range(NB_NEOPIXEL): + np[i] = (0, 0, 255) + time.sleep(0.5) + np.write()