Difference between revisions of "BakeBit - Green LED"
From FriendlyELEC WiKi
(→示例程序:LED Blink) |
(→相关资料) |
||
Line 85: | Line 85: | ||
The BakeBit LED keeps blinking and the interval between two blinks is one second. | The BakeBit LED keeps blinking and the interval between two blinks is one second. | ||
− | == | + | ==Resources== |
*[Schematic]([http://wiki.friendlyarm.com/wiki/images/2/2e/08-SCHEMATIC_LED.pdf BakeBit - Green LED.pdf]) | *[Schematic]([http://wiki.friendlyarm.com/wiki/images/2/2e/08-SCHEMATIC_LED.pdf BakeBit - Green LED.pdf]) | ||
− | *[BakeBit | + | *[BakeBit Github Project Page](https://github.com/friendlyarm/BakeBit) |
− | *[BakeBit Starter | + | *[BakeBit Starter Kit User's Manual](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_en.pdf) |
Revision as of 14:42, 14 December 2016
Contents
1 Introduction
- The BakeBit - Green LED is an LED module. This module has a a triode which is used to turn the LED on or off. There is a potentiometer in series connection with the LED. When users adjust the potentiometer the LED's luminance will be changed accordingly.Or you input PWM signals to control the the LED's luminance.
2 Hardware Spec
- Standard 2.0mm 4-Pin BakeBit Interface
- LED's luminance adjustable
- Digital Input
- Pin Description:
Pin | Description |
GND | Ground |
5V | 5V Supply Voltage |
NC | Not Connected |
SIG | Signal |
3 Code Sample:LED Blink
3.1 Hardware Connection
连接LED到NanoHUB扩展板的D3接口:
3.2 Source Code
import time from bakebit import * # Connect the BakeBit LED to digital port D3 led = 3 pinMode(led,"OUTPUT") time.sleep(1) print ("This example will blink a BakeBit LED connected to the BakeBit on the port labeled D3.\nIf you're having trouble seeing the LED blink, be sure to check the LED connection and the port number.\nYou may also try reversing the direction of the LED on the sensor.") print (" ") print ("Connect the LED to the port labele D3!" ) while True: try: #Blink the LED digitalWrite(led,1) # Send HIGH to switch on LED print ("LED ON!") time.sleep(1) digitalWrite(led,0) # Send LOW to switch off LED print ("LED OFF!") time.sleep(1) except KeyboardInterrupt: # Turn LED off before stopping digitalWrite(led,0) break except IOError: # Print "Error" if communication error encountered print ("Error")
3.3 Run Code Sample
Before you run the code sample you need to follow the steps in bakebit tutorial to install the BakeBit package.
Enter the "BakeBit/Software/Python" directory and run the "bakebit_led_blink.py" program:
cd ~/BakeBit/Software/Python sudo python bakebit_led_blink.py
3.4 Observation
The BakeBit LED keeps blinking and the interval between two blinks is one second.
4 Resources
- [Schematic](BakeBit - Green LED.pdf)
- [BakeBit Github Project Page](https://github.com/friendlyarm/BakeBit)
- [BakeBit Starter Kit User's Manual](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_en.pdf)