Editor Version ×
Standard

1.Easy to use and quick to get started

2.The process supports design scales of 300 devices or 1000 pads

3.Supports simple circuit simulation

4.For students, teachers, creators

Profession

1.Brand new interactions and interfaces

2.Smooth support for design sizes of over 5,000 devices or 10,000 pads

3.More rigorous design constraints, more standardized processes

4.For enterprises, more professional users

Ongoing

STD Grove LED Bar v2.0

License:

Mode: Editors' pick

  • 2.3k
  • 0
  • 0
Update time: 2021-04-11 22:52:39
Creation time: 2016-01-15 11:47:48
Description
Grove - LED Bar --------------- Grove – LED Bar is comprised of a 10 segment LED gauge bar and an MY9221 LED controlling chip. It can be used as a 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 the rest green. 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: Each LED segment can be controlled individually via code; Grove module; Plug-and-play; Can be cascaded for a larger display; Flexible power option, supports 3-5.5DC; Available demo code; 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) 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 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) 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" 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 For more detail, please visit: http://www.seeedstudio.com/item_detail.html?p_id=2474
Design Drawing
schematic diagram
1 /
PCB
1 /
The preview image was not generated, please save it again in the editor.
ID Name Designator Footprint Quantity
1 100nF C10 0603 1
2 LED-20P U1 20P-DIP-2.54-25.5X10.1X8.4H 1
3 MY9221 U6 TSSOP24EP 1
4 10k R13 0603 1
5 2.7k_1% R11,R9,R7 0603 3
6 1k R16,R17 0603 2
7 LOGO-OSHW-FILL LOGO1 OSHW_FILLX150_NOTEXT 1
8 HEADER-4P J2 4P-2.54-90 1
9 HEADER-4P J3 4P-2.54-90D-FEMALE 1
10 TWIG U2 2U-DIM-W-DRILL 1
11 TWIG-4P-2.0 J4 4P-2.0 1
12 LOGO-TWIG U$1 TWIGLOGO_SMALL 1

Unfold

Project Attachments
Empty
Project Members
Target complaint
Related Projects
Change a batch
Loading...
Add to album ×

Loading...

reminder ×

Do you need to add this project to the album?

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn