Difference between revisions of "BakeBit - Green LED"
From FriendlyELEC WiKi
(→介绍) |
|||
Line 1: | Line 1: | ||
[[BakeBit - Green LED/zh|查看中文]] | [[BakeBit - Green LED/zh|查看中文]] | ||
− | == | + | ==Introduction== |
[[File:BakeBit - Green LED.jpg|thumb|Green LED]] | [[File:BakeBit - Green LED.jpg|thumb|Green LED]] | ||
− | *BakeBit - Green | + | * 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. |
==特性== | ==特性== |
Revision as of 14:25, 14 December 2016
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 特性
- 使用标准的2.0mm 4 Pin BakeBit接口
- LED亮度可调节
- 数字信号输入
- 引脚说明:
名称 | 描述 |
GND | 地 |
5V | 电源5V |
NC | 空 |
SIG | 信号 |
3 示例程序:LED Blink
3.1 硬件连接
连接LED到NanoHUB扩展板的D3接口:
3.2 示例源代码
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 运行示例
假设你已经参考bakebit教程安装了BakeBit源代码,
要运行示例程序,可以在开发板上进入 BakeBit/Software/Python目录,运行bakebit_led_blink.py:
cd ~/BakeBit/Software/Python sudo python bakebit_led_blink.py
3.4 运行结果
BakeBit LED持续闪烁,闪烁的时间简隔是1秒钟。
4 相关资料
- [Schematic](BakeBit - Green LED.pdf)
- [BakeBit Github项目](https://github.com/friendlyarm/BakeBit)
- [BakeBit Starter Kit手册](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_cn.pdf)