Difference between revisions of "BakeBit - Green LED"

From FriendlyELEC WiKi
Jump to: navigation, search
 
(10 intermediate revisions by the same user not shown)
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 LED是一个发光二极管模块,模块使用了一个三极管控制发光二极管的导通或关闭,并在发光二极管上串接了一个电位器,通过调节电位器接入电路的阻值,调整流过发光二极管的电流,从而改变发光二极管的亮度。也可使用可变占空比的PWM信号软件调节二极管发光的亮度。
+
* The BakeBit - Green LED is an LED module. This module has 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 LED's luminance.
  
==特性==
+
==Hardware Spec==
* 使用标准的2.0mm 4 Pin BakeBit接口
+
* Standard 2.0mm 4-Pin BakeBit Interface
* LED亮度可调节
+
* LED's luminance adjustable
* 数字信号输入
+
* Digital Input
 
[[File:BakeBit Green LED PCB.png | frameless|300px|BakeBit - Green LED]]
 
[[File:BakeBit Green LED PCB.png | frameless|300px|BakeBit - Green LED]]
  
* 引脚说明:
+
* Pin Description:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
|名称 || 描述
+
|Pin || Description
 
|-
 
|-
|GND  ||
+
|GND  || Ground
 
|-
 
|-
|5V    || 电源5V
+
|5V    || 5V Supply Voltage
 
|-
 
|-
|NC    ||
+
|NC    || Not Connected
 
|-
 
|-
|SIG  || 信号
+
|SIG  || Signal
 
|}
 
|}
== 示例程序:LED Blink ==
 
  
=== 硬件连接 ===
+
== Code Sample:LED Blink ==
连接LED到NanoHUB扩展板的D3接口:
+
 
 +
=== Hardware Setup ===
 +
Connect the LED module to the NanoHat Hub's D3.
  
 
::{| class="wikitable"
 
::{| class="wikitable"
Line 35: Line 36:
 
|}
 
|}
  
=== 示例源代码 ===
+
=== Source Code ===
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Line 71: Line 72:
 
[https://github.com/friendlyarm/BakeBit/blob/master/Software/Python/bakebit_led_blink.py Github]
 
[https://github.com/friendlyarm/BakeBit/blob/master/Software/Python/bakebit_led_blink.py Github]
  
=== 运行示例 ===
+
=== Run Code Sample ===
+
 
假设你已经参考[http://wiki.friendlyarm.com/bakebit bakebit教程]安装了BakeBit源代码,<br />
+
Before you run the code sample you need to follow the steps in [http://wiki.friendlyarm.com/bakebit bakebit tutorial] to install the BakeBit package.<br />
要运行示例程序,可以在开发板上进入 BakeBit/Software/Python目录,运行bakebit_led_blink.py:
+
Enter the "BakeBit/Software/Python" directory and run the "bakebit_led_blink.py" program:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd ~/BakeBit/Software/Python
 
cd ~/BakeBit/Software/Python
Line 80: Line 81:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== 运行结果 ===
+
=== Observation ===
  
BakeBit LED持续闪烁,闪烁的时间简隔是1秒钟。
+
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 Github项目](https://github.com/friendlyarm/BakeBit)
+
*[BakeBit Github Project Page](https://github.com/friendlyarm/BakeBit)
*[BakeBit Starter Kit手册](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_cn.pdf)
+
*[BakeBit Starter Kit User's Manual](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_en.pdf)
 +
 
 +
==Update Log==
 +
===Dec-14-2016===
 +
* Released English version
 +
 
 +
===Jan-19-2017===
 +
* Renamed "NEO-Hub" to "NanoHat-Hub"
 +
 
 +
===Jan-20-2017===
 +
* Renamed "NanoHat-Hub" to "NanoHat Hub"

Latest revision as of 08:19, 20 January 2017

查看中文

1 Introduction

Green LED
  • The BakeBit - Green LED is an LED module. This module has 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 LED's luminance.

2 Hardware Spec

  • Standard 2.0mm 4-Pin BakeBit Interface
  • LED's luminance adjustable
  • Digital Input

BakeBit - Green LED

  • Pin Description:
Pin Description
GND Ground
5V 5V Supply Voltage
NC Not Connected
SIG Signal

3 Code Sample:LED Blink

3.1 Hardware Setup

Connect the LED module to the NanoHat Hub's D3.

LED-1.jpg LED-2.jpg

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")

Github

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

5 Update Log

5.1 Dec-14-2016

  • Released English version

5.2 Jan-19-2017

  • Renamed "NEO-Hub" to "NanoHat-Hub"

5.3 Jan-20-2017

  • Renamed "NanoHat-Hub" to "NanoHat Hub"