Difference between revisions of "BakeBit - Button/zh"
From FriendlyELEC WiKi
(→硬件连接) |
(→代码说明) |
||
Line 30: | Line 30: | ||
[[File:BakeBit - Button_nanopi_NEO.jpg|frameless|600px|BakeBit - Button_nanopi_NEO]] | [[File:BakeBit - Button_nanopi_NEO.jpg|frameless|600px|BakeBit - Button_nanopi_NEO]] | ||
− | == | + | ==示例程序== |
下面是一个简单的BakeBit - Button模块的例子,当没有按键按下时,输出为1,当有按键按下时,输出为0. | 下面是一个简单的BakeBit - Button模块的例子,当没有按键按下时,输出为1,当有按键按下时,输出为0. | ||
+ | |||
+ | <syntaxhighlight lang="python"> | ||
+ | import time | ||
+ | import bakebit | ||
+ | |||
+ | # Connect the BakeBit Button to digital port D3 | ||
+ | # SIG,NC,VCC,GND | ||
+ | button = 3 | ||
+ | |||
+ | bakebit.pinMode(button,"INPUT") | ||
+ | |||
+ | while True: | ||
+ | try: | ||
+ | print(bakebit.digitalRead(button)) | ||
+ | time.sleep(.5) | ||
+ | |||
+ | except IOError: | ||
+ | print ("Error") | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==运行示例== | ||
+ | |||
+ | test | ||
==相关资料== | ==相关资料== | ||
*[Schematic]([http://wiki.friendlyarm.com/wiki/images/8/8a/05-SCHEMATIC_Button.pdf BakeBit - Button.pdf]) | *[Schematic]([http://wiki.friendlyarm.com/wiki/images/8/8a/05-SCHEMATIC_Button.pdf BakeBit - Button.pdf]) |
Revision as of 06:38, 22 November 2016
1 介绍
- BakeBit - Button是一个瞬时(非自锁)按钮开关模块,用于检测按键事件,按钮被释放后自动恢复到常态。
- 在按钮未被按下时模块输出高电平,按钮被按下后输出低电平。
2 特性
- 使用标准的2.0mm 4 Pin BakeBit接口
- 数字信号输出
- PCB尺寸(mm):20x24
- 引脚说明:
名称 | 描述 |
GND | 地 |
5V | 电源5V |
NC | 空 |
SIG | 信号 |
3 硬件连接
BakeBit - Button模块需要搭配NEO_Hub模块才能连接到NanoPi NEO上使用。连接BakeBit - Button模块到NEO_Hub模块的D3口,并叠加连接NEO_Hub模块到NanoPi NEO上,参考下图连接模块:
4 示例程序
下面是一个简单的BakeBit - Button模块的例子,当没有按键按下时,输出为1,当有按键按下时,输出为0.
import time import bakebit # Connect the BakeBit Button to digital port D3 # SIG,NC,VCC,GND button = 3 bakebit.pinMode(button,"INPUT") while True: try: print(bakebit.digitalRead(button)) time.sleep(.5) except IOError: print ("Error")
5 运行示例
test
6 相关资料
- [Schematic](BakeBit - Button.pdf)