Grove - Barra LED
Grove – Barra LED está compuesta por una barra de medición LED de 10 segmentos y un chip controlador de LED MY9221. Se puede usar como indicador para la vida útil restante de la batería, voltaje, nivel de agua, volumen de música u otros valores que requieren una visualización gradual. Hay 10 barras LED en el gráfico de barras LED: una roja, una amarilla, una verde claro y siete barras verdes. El código de demostración está disponible para que puedas empezar rápidamente. Enciende los LEDs secuencialmente de rojo a verde, por lo que toda la barra gráfica se ilumina al final. ¿Quieres ir más lejos? Adelante y programa tu propio efecto.

Versión

Versión del Producto | Cambios | Fecha de Lanzamiento |
---|---|---|
Grove – Barra LED V1 | Inicial | Junio 2014 |
Grove – Barra LED V2 | Mejoró la fuente de alimentación | Oct 2015 |
Características
- Voltaje de Entrada: 3.3V/5V
- Cada segmento LED puede ser controlado individualmente mediante código
- Pantalla intuitiva
- Opción de alimentación flexible, soporta 3-5.5DC
- Código de demostración disponible
- Biblioteca compatible con Suli
Más detalles sobre los módulos Grove consulte Sistema Grove
Especificación
Parámetro | Valor/Rango |
---|---|
Voltaje de operación | 3.3/5V |
Temperatura de Operación | -20℃ a +80℃ |
Longitud de Onda de Emisión Pico-ROJO(Corriente 20mA) | 630-637nm |
Longitud de Onda de Emisión Pico-Verde Amarillo(Corriente 20mA) | 570-573nm |
Longitud de Onda de Emisión Pico-Amarillo(Corriente 20mA) | 585-592nm |
Intensidad Luminosa Por Segmento-ROJO(Corriente 20mA) | 50-70mcd |
Intensidad Luminosa Por Segmento-Verde Amarillo(Corriente 20mA) | 28-35mcd |
Intensidad Luminosa Por Segmento-Amarillo(Corriente 20mA) | 45-60mcd |
Segmento LED | 10 |
Tamaño | 40mm * 20mm |
Plataformas Compatibles
Arduino | Raspberry Pi |
---|---|
Las plataformas mencionadas anteriormente como compatibles son una indicación de la compatibilidad de software o teórica del módulo. Solo proporcionamos biblioteca de software o ejemplos de código para la plataforma Arduino en la mayoría de los casos. No es posible proporcionar biblioteca de software / código de demostración para todas las plataformas MCU posibles. Por lo tanto, los usuarios tienen que escribir su propia biblioteca de software.
Primeros Pasos
Si esta es la primera vez que trabajas con Arduino, te recomendamos firmemente que veas Primeros Pasos con Arduino antes de comenzar.
Jugar con Arduino
Hardware
- Paso 1. Prepara los siguientes elementos:
Seeeduino V4.2 | Base Shield | Grove-LED Bar |
---|---|---|
Obtener Uno Ahora | Obtener Uno Ahora | Obtener Uno Ahora |
- Paso 2. Conecta Grove-LED Bar al puerto D8 del Grove-Base Shield.
- Paso 3. Conecta Grove - Base Shield al Seeeduino.
- Paso 4. Conecta el Seeeduino a la PC mediante un cable USB.
Si no tenemos Grove Base Shield, también podemos conectar directamente Grove-LED Bar al Seeeduino como se muestra a continuación.
Seeeduino | Grove-LED Bar |
---|---|
5V | Rojo |
GND | Negro |
D9 | Blanco |
D8 | Amarillo |
Software
-
Paso 1. Descarga la Librería Grove - LED Bar desde Github
-
Paso 2. Consulta Cómo instalar librería para instalar la librería para Arduino.
-
Paso 3. Reinicia el IDE de Arduino. Abre el ejemplo "Level" a través de la ruta: File --> Examples --> Grove LED Bar --> Level.
- Paso 4. Sube la demostración. Si no sabes cómo subir el código, por favor revisa cómo subir código.
El resultado debería ser así:
Jugar Con Raspberry Pi
Hardware
- Paso 1. Prepara los siguientes elementos:
Raspberry pi | GrovePi_Plus | Grove-LED Bar |
---|---|---|
Consigue Uno Ahora | Consigue Uno Ahora | Consigue Uno Ahora |
-
Paso 2. Conecta el GrovePi_Plus al Raspberry.
-
Paso 3. Conecta Grove-LED Bar al puerto D5 del GrovePi_Plus.
-
Paso 4. Conecta el Raspberry a la PC a través del cable USB.
Software
-
Paso 1. Sigue Setting Software para configurar el entorno de desarrollo.
-
Paso 2. Sigue Updating the Firmware para actualizar el firmware más reciente del GrovePi.
En esta wiki usamos la ruta ~/GrovePi/ en lugar de /home/pi/Desktop/GrovePi, necesitas asegurarte de que el Paso 2 y el Paso 3 usen la misma ruta.
Te sugerimos firmemente que actualices el firmware, o para algunos sensores podrías obtener errores.
Si estás usando Raspberry Pi con Raspberrypi OS >= Bullseye, tienes que usar esta línea de comandos solo con Python3.
- Paso 3. Clona el repositorio de Github con Git.
cd ~
git clone https://github.com/DexterInd/GrovePi.git
- Paso 4. Navega al directorio de demostraciones:
cd yourpath/GrovePi/Software/Python/
Aquí está el código grove_ledbar.py.
import time
import grovepi
import random
# Connect the Grove LED Bar to digital port D5
# DI,DCKI,VCC,GND
ledbar = 5
grovepi.pinMode(ledbar,"OUTPUT")
time.sleep(1)
i = 0
# LED Bar methods
# grovepi.ledBar_init(pin,orientation)
# grovepi.ledBar_orientation(pin,orientation)
# grovepi.ledBar_setLevel(pin,level)
# grovepi.ledBar_setLed(pin,led,state)
# grovepi.ledBar_toggleLed(pin,led)
# grovepi.ledBar_setBits(pin,state)
# grovepi.ledBar_getBits(pin)
while True:
try:
print "Test 1) Initialise - red to green"
# ledbar_init(pin,orientation)
# orientation: (0 = red to green, 1 = green to red)
grovepi.ledBar_init(ledbar, 0)
time.sleep(.5)
print "Test 2) Set level"
# ledbar_setLevel(pin,level)
# level: (0-10)
for i in range(0,11):
grovepi.ledBar_setLevel(ledbar, i)
time.sleep(.2)
time.sleep(.3)
grovepi.ledBar_setLevel(ledbar, 8)
time.sleep(.5)
grovepi.ledBar_setLevel(ledbar, 2)
time.sleep(.5)
grovepi.ledBar_setLevel(ledbar, 5)
time.sleep(.5)
print "Test 3) Switch on/off a single LED"
# ledbar_setLed(pin,led,state)
# led: which led (1-10)
# state: off or on (0,1)
grovepi.ledBar_setLed(ledbar, 10, 1)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 9, 1)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 8, 1)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 1, 0)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 2, 0)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 3, 0)
time.sleep(.5)
print "Test 4) Toggle a single LED"
# flip a single led - if it is currently on, it will become off and vice versa
# ledbar_toggleLed(ledbar, led)
grovepi.ledBar_toggleLed(ledbar, 1)
time.sleep(.5)
grovepi.ledBar_toggleLed(ledbar, 2)
time.sleep(.5)
grovepi.ledBar_toggleLed(ledbar, 9)
time.sleep(.5)
grovepi.ledBar_toggleLed(ledbar, 10)
time.sleep(.5)
print "Test 5) Set state - control all leds with 10 bits"
# ledbar_setBits(ledbar, state)
# state: (0-1023) or (0x00-0x3FF) or (0b0000000000-0b1111111111) or (int('0000000000',2)-int('1111111111',2))
for i in range(0,32):
grovepi.ledBar_setBits(ledbar, i)
time.sleep(.2)
time.sleep(.3)
print "Test 6) Get current state"
# state = ledbar_getBits(ledbar)
# state: (0-1023) a bit for each of the 10 LEDs
state = grovepi.ledBar_getBits(ledbar)
print "with first 5 leds lit, the state should be 31 or 0x1F"
print state
# bitwise shift five bits to the left
state = state << 5
# the state should now be 992 or 0x3E0
# when saved the last 5 LEDs will be lit instead of the first 5 LEDs
time.sleep(.5)
print "Test 7) Set state - save the state we just modified"
# ledbar_setBits(ledbar, state)
# state: (0-1023) a bit for each of the 10 LEDs
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.5)
print "Test 8) Swap orientation - green to red - current state is preserved"
# ledbar_orientation(pin,orientation)
# orientation: (0 = red to green, 1 = green to red)
# when you reverse the led bar orientation, all methods know how to handle the new LED index
# green to red
grovepi.ledBar_orientation(ledbar, 1)
time.sleep(.5)
# red to green
grovepi.ledBar_orientation(ledbar, 0)
time.sleep(.5)
# green to red
grovepi.ledBar_orientation(ledbar, 1)
time.sleep(.5)
print "Test 9) Set level, again"
# ledbar_setLevel(pin,level)
# level: (0-10)
# note the red LED is now at index 10 instead of 1
for i in range(0,11):
grovepi.ledBar_setLevel(ledbar, i)
time.sleep(.2)
time.sleep(.3)
print "Test 10) Set a single LED, again"
# ledbar_setLed(pin,led,state)
# led: which led (1-10)
# state: off or on (0,1)
grovepi.ledBar_setLed(ledbar, 1, 0)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 3, 0)
time.sleep(.5)
grovepi.ledBar_setLed(ledbar, 5, 0)
time.sleep(.5)
print "Test 11) Toggle a single LED, again"
# ledbar_toggleLed(ledbar, led)
grovepi.ledBar_toggleLed(ledbar, 2)
time.sleep(.5)
grovepi.ledBar_toggleLed(ledbar, 4)
time.sleep(.5)
print "Test 12) Get state"
# state = ledbar_getBits(ledbar)
# state: (0-1023) a bit for each of the 10 LEDs
state = grovepi.ledBar_getBits(ledbar)
# the last 5 LEDs are lit, so the state should be 992 or 0x3E0
# bitwise shift five bits to the right
state = state >> 5
# the state should now be 31 or 0x1F
print "Test 13) Set state, again"
# ledbar_setBits(ledbar, state)
# state: (0-1023) a bit for each of the 10 LEDs
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.5)
print "Test 14) Step"
# step through all 10 LEDs
for i in range(0,11):
grovepi.ledBar_setLevel(ledbar, i)
time.sleep(.2)
time.sleep(.3)
print "Test 15) Bounce"
# switch on the first two LEDs
grovepi.ledBar_setLevel(ledbar, 2)
# get the current state (which is 0x3)
state = grovepi.ledBar_getBits(ledbar)
# bounce to the right
for i in range(0,9):
# bit shift left and update
state <<= 1;
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.2)
# bounce to the left
for i in range(0,9):
# bit shift right and update
state >>= 1;
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.2)
time.sleep(.3)
print "Test 16) Random"
for i in range(0,21):
state = random.randint(0,1023)
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.2)
time.sleep(.3)
print "Test 17) Invert"
# set every 2nd LED on - 341 or 0x155
state = 341
for i in range(0,5):
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.2)
# bitwise XOR all 10 LEDs on with the current state
state = 0x3FF ^ state
grovepi.ledBar_setBits(ledbar, state)
time.sleep(.2)
time.sleep(.3)
print "Test 18) Walk through all possible combinations"
for i in range(0,1024):
grovepi.ledBar_setBits(ledbar, i)
time.sleep(.1)
time.sleep(.4)
except KeyboardInterrupt:
grovepi.ledBar_setBits(ledbar, 0)
break
except IOError:
print "Error"
- Paso 5. Ejecuta la demostración.
sudo python3 grove_ledbar.py
Visor Esquemático en Línea
Recursos
- [Eagle&PDF]Archivo Eagle de Grove - LED Bar
- [Librería]Librería de Grove - LED Bar
- [Librería]Librería Compatible con Suli
- [Hoja de Datos]Hoja de Datos MY9221
- [Más Lectura]Pistola Láser de Madera
Proyectos
Grove LED Bar v2.0: Calliope Mini está equipado con dos conectores Grove. En este proyecto, quiero explorar cómo comunicarse con estas partes Grove de Seeed.
Controlador de Grove LED Bar con el Bean+: ¡Aprende los conceptos básicos de usar componentes Grove populares con el nuevo LightBlue Bean+ para comenzar a construir tus propios proyectos!
Soporte Técnico y Discusión de Productos
¡Gracias por elegir nuestros productos! Estamos aquí para brindarle diferentes tipos de soporte para asegurar que su experiencia con nuestros productos sea lo más fluida posible. Ofrecemos varios canales de comunicación para satisfacer diferentes preferencias y necesidades.