Grove - LED Bar. Introduction. Features

Similar documents
Grove - 4-Digit Display

Adafruit CCS811 Air Quality Sensor

Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

Adafruit Color Sensors

Naughty or Nice Machine

Adafruit DRV2605 Haptic Controller Breakout

Adafruit GPIO Expander Bonnet for Raspberry Pi Created by Kattni Rembor. Last updated on :12:47 PM UTC

Adafruit AS channel Visible Light Sensor

Adafruit MPRLS Ported Pressure Sensor Breakout

Adafruit AMG8833 8x8 Thermal Camera Sensor

MLX90393 Wide-Range 3-Axis Magnetometer

Monochrome OLED Breakouts

Adafruit MMA8451 Accelerometer Breakout

Adafruit APDS9960 breakout

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

TSL2561 Luminosity Sensor

Adafruit SGP30 TVOC/eCO2 Gas Sensor

0.96" mini Color OLED

Adafruit AM2320 Sensor

Adafruit PowerBoost 500 Shield

Adafruit Si5351 Clock Generator Breakout

Introducing Adafruit Trellis

Adafruit 1.27" and 1.5" Color OLED Breakout Board

Adafruit Si7021 Temperature + Humidity Sensor

Large Pi-based Thermometer and Clock

Bunny Ears with MakeCode

Adafruit MMA8451 Accelerometer Breakout

Adafruit Capacitive Touch Sensor Breakouts

Adafruit WINC1500 WiFi Shield for Arduino

Adafruit GPS Hat in Windows IoT Core

Adafruit SI7021 Library Documentation

Adafruit ATWINC1500 WiFi Breakout

Adafruit 8x16 LED Matrix FeatherWing

1.8" TFT Display Breakout and Shield

FLORA TV-B-Gone. Created by Becky Stern. Last updated on :32:57 PM UTC

RGB LCD Shield. Created by lady ada. Last updated on :48:40 PM UTC

MCP Bit DAC Tutorial

NeoPixel Bike Light. Created by Ruiz Brothers. Last updated on :43:46 PM UTC

Introducing Circuit Playground

Getting Started with FLORA

i2c/spi LCD Backpack Created by lady ada Last updated on :11:04 PM UTC

Joy Featherwing. Created by Dean Miller. Last updated on :03:07 PM UTC

IS31FL x9 Charlieplexed PWM LED Driver

Adafruit eink Display Breakouts

NeoPixie Dust Bag with Circuit Playground Express

Getting Started with FLORA

NeoMatrix 8x8 Word Clock

Adafruit IO Basics: Servo

Adafruit 2.4" TFT FeatherWing

Adafruit 8x16 LED Matrix FeatherWing

Adafruit MMA8451 Accelerometer Breakout

Adafruit 7-Segment LED FeatherWings

Prophet 600 GliGli mod

Getting Started with FLORA

Clockwork Goggles. Created by John Park. Last updated on :03:10 PM UTC

NeoPixel Basketball Hoop

Wind Blowing Emoji Prop

NeoPixel Ring Bangle Bracelet

14-Segment Alpha-numeric LED FeatherWing

OLED 2864 Display module (SKU:TOY0007)

Adafruit Mini TFT with Joystick Featherwing

Flora Wearable GPS. Created by Becky Stern. Last updated on :32:36 PM UTC

Adafruit 3.5" 480x320 TFT FeatherWing

Trinket-Powered Conference Room Occupancy Display

Introducing Circuit Playground

Sino:bit with Arduino

Adafruit LED Sequins. Created by Becky Stern. Last updated on :02:00 AM UTC

Adafruit Pi Cobbler Kit

OBIS Scientific Remote

MCP Bit DAC Tutorial

Adafruit DS3231 Precision RTC Breakout

Crickit Dancing Marionette Kit Created by Dano Wall. Last updated on :03:11 PM UTC

Adafruit LED Backpacks

Adafruit DRV2605 Haptic Controller Breakout

Circuit Playground Digital Input

Morning Star POV Double Staffs

MiniPOV4 - DIY Full-Color Persistence of Vision & Light-Painting Kit

Alarm.com Wi-Fi Doorbell Camera and Slim Line - Installation Guide

Neon LED Signs. Created by John Park. Last updated on :11:09 PM UTC

Adabot Operation Game

Adafruit IO Basics: ESP Arduino

PyPortal NeoPixel Color Picker Created by Kattni Rembor. Last updated on :42:41 PM UTC

Feather Weather Lamp. Created by Ruiz Brothers. Last updated on :54:26 PM UTC

Adafruit I2C FRAM Breakout

Sewable NeoPixels. Created by Becky Stern. Last updated on :50:14 PM EDT

BeagleBone. Created by lady ada. Last updated on :46:10 PM UTC

Crawling Baby Sea Turtle Robot

Adafruit PCF8523 Real Time Clock

Steam Heat Retrofit for Coover Hall

LED Lightbox. Created by Sam Clippinger. Last updated on :50:00 AM UTC

Adafruit MAX31865 RTD PT100 or PT1000 Amplifier

Adafruit Mini TFT " 160x80

Adafruit 3.5" 480x320 TFT FeatherWing

Adafruit LED Backpacks

Datalogging Hat with FLORA BLE

Interior Purse Light. Created by Becky Stern. Last updated on :41:08 PM UTC

Android GBoard Morse Code Control with Circuit Playground Express

Adafruit LIS3DH Triple-Axis Accelerometer Breakout

Color Swatch Add-on User Guide

Adafruit Feather 32u4 Basic Proto

Transcription:

Grove - LED Bar Introduction 3.3V 5.0V Digital Grove LED Bar is comprised of a 10 segment LED gauge bar and an MY9221 LED controlling chip. It can be used as an indicator for remaining battery life, voltage, water level, music volume or other values that require a gradient display. There are 10 LED bars in the LED bar graph: one red, one yellow, one light green, and seven green bars. Demo code is available to get you up and running quickly. It lights up the LEDs sequentially from red to green, so the entire bar graph is lit up in the end. Want to go further? Go ahead and code your own effect. Features Input Voltage: 3.3V/5V Each LED segment can be controlled individually via code Intuitive display Flexible power option, supports 3-5.5DC Available demo code Suli-compatible Library Tip More details about Grove modules please refer to Grove System

Platforms Supported Arduino Wio BeagleBone Raspberry Pi LinkIt ONE Caution The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library. Note More details about Suli-compatible Library, please refer to Suli Demonstration With Arduino This is a simple demo which can you help you to start with Grove - LED Bar quickly. We need a Seeeduino V3.0 and a Grove - Base Shield as well. Hardware Installation Plug the Grove - LED Bar onto the digital port 8 on Grove - Base Shield, and then plug the base shield onto Arduino. Download Code and Upload You can download the library in github, click here, then extract it to libraries folder of Arduino. Then open Arduino IDE, File -> examples -> LED_Bar -> Level, you can open the demo code.

Click Upload to Upload the code, if you have any problem about how to start Arduino, please click here for some help. Working Now Your Grove - LED Bar is working now, it s shine.

With Raspberry Pi 1.You should have got a raspberry pi and a grovepi or grovepi+. 2.You should have completed configuring the development enviroment, otherwise follow here. 3.Connection Plug the sensor to grovepi socket D3 by using a grove cable. 4.Navigate to the demos directory: cd yourpath/grovepi/software/python/ To see the code nano grove_ledbar.py # "Ctrl+x" to exit # 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) print "Test 2) Set level" # ledbar_setlevel(pin,level) # level: (0-10) for i in range(0,11): grovepi.ledbar_setlevel(ledbar, i) grovepi.ledbar_setlevel(ledbar, 8) grovepi.ledbar_setlevel(ledbar, 2) grovepi.ledbar_setlevel(ledbar, 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)

grovepi.ledbar_setled(ledbar, 9, 1) grovepi.ledbar_setled(ledbar, 8, 1) grovepi.ledbar_setled(ledbar, 1, 0) grovepi.ledbar_setled(ledbar, 2, 0) grovepi.ledbar_setled(ledbar, 3, 0) 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) grovepi.ledbar_toggleled(ledbar, 2) grovepi.ledbar_toggleled(ledbar, 9) grovepi.ledbar_toggleled(ledbar, 10) 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) 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 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 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) # red to green

grovepi.ledbar_orientation(ledbar, 0) # green to red grovepi.ledbar_orientation(ledbar, 1) 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) 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) grovepi.ledbar_setled(ledbar, 3, 0) grovepi.ledbar_setled(ledbar, 5, 0) print "Test 11) Toggle a single LED, again" # ledbar_toggleled(ledbar, led) grovepi.ledbar_toggleled(ledbar, 2)

grovepi.ledbar_toggleled(ledbar, 4) 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 print "Test 14) Step" # step through all 10 LEDs for i in range(0,11): grovepi.ledbar_setlevel(ledbar, i) 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; # bounce to the left for i in range(0,9): # bit shift right and update state >>= 1; print "Test 16) Random" for i in range(0,21): state = random.randint(0,1023) print "Test 17) Invert" # set every 2nd LED on - 341 or 0x155 state = 341 for i in range(0,5): # bitwise XOR all 10 LEDs on with the current state state = 0x3FF ^ state

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" 5.Run the demo. sudo python grove_ledbar.py 6.This demo may not work if your grovepi dosen t have the newest firmware, update the firmware. cd yourpath/grovepi/firmware sudo./firmware_update.sh Project Inspired by OVERWATCH, we have made a very cool Wooden Laser Gun toy for fun these day!

The Wooden Laser Gun and the Gun Target are all based on an Arduino board called Seeeduino Lotus. The laser emitter on the Laser Gun is controlled to fire laser pulse to activate the Gun Target. And there are 3 light sensors on the Gun Target to detect the laser pulse. It seems very simple right? If you are interested in our project, please make one for yourself or your child! It s worth to spend one day DIY it as a Xmas present.