Exemple tout basique avec une animation autour des couleurs

This commit is contained in:
Pierrick C 2018-09-11 17:54:01 +02:00
parent 3896ba5f3e
commit 4efb16267d
1 changed files with 64 additions and 0 deletions

64
code/main_1.py Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
"""
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)