Outils pour utilisateurs

Outils du site


start:micro-bit:neopixel

Micro-bit Neopixel


Transformez votre Micro:bit en horloge, chronomètre, boussole ou affichage avancé avec le Halo Zip

Le Zip Halo est l'équivalent de nos anneaux NeoPixel mais spécialement adapté pour le BBC Microbit. Le Zip Halo permet d'ajouter une myriade de couleurs dans votre prochain projet BBC micro:bit. Le Halo est équipé de 24 LED RGB intelligentes (aussi nommée ZIP LEDs ou NeoPixel LEDs), chacune pouvant être commande individuellement pour recevoir une couleur. Cela signifie que chaque LED peut afficher un large spectre de couleur, permettant de réaliser des effets lumineux incroyables comme par exemple un effet arc-en-ciel.

Programmation

En micropython

Neopixel en micropython 001 EN

exemple_neopixel_micropython.py
 
"""
    neopixel_random.py
 
    Repeatedly displays random colours onto the LED strip.
    This example requires a strip of 8 Neopixels (WS2812) connected to pin0.
 
"""
from microbit import *
import neopixel
from random import randint
 
# Setup the Neopixel strip on pin0 with a length of 8 pixels
np = neopixel.NeoPixel(pin0, 8)
 
while True:
    #Iterate over each LED in the strip
 
    for pixel_id in range(0, len(np)):
        red = randint(0, 60)
        green = randint(0, 60)
        blue = randint(0, 60)
 
        # Assign the current LED a random red, green and blue value between 0 and 60
        np[pixel_id] = (red, green, blue)
 
        # Display the current pixel data on the Neopixel strip
        np.show()
        sleep(100)
 

En javascript

Neopixel en javascript 001 EN

exemple_neopixel001.js
let ring: neopixel.Strip = null
ring = neopixel.create(DigitalPin.P2, 24, NeoPixelMode.RGB)
basic.forever(function () {
    for (let index = 0; index <= 23; index++) {
        ring.setPixelColor(index, neopixel.colors(NeoPixelColors.Red))
        ring.show()
        basic.pause(50)
        ring.setPixelColor(index, neopixel.rgb(16, 16, 16))
        ring.show()
    }
})
/home/chanteri/www/fablab37110/data/pages/start/micro-bit/neopixel.txt · Dernière modification : 2023/01/27 16:08 de 127.0.0.1