- BakeBit - Buzzer是一个无源蜂鸣器模块,无源蜂鸣器内部有音圈和钼片,输入2.7KHz的PWM信号时,PWM信号通过绕在支架上的线包在支架的芯柱上产生一交变的磁通,交变的磁通和磁环恒定磁通进行叠加,使钼片以给定的PWM信号频率振动并配合共振腔发声。
- 通过调整输入PWM信号的频率即可使无源蜂鸣器发出频率不同的声音。
- BakeBit - Button是一个瞬时(非自锁)按钮开关模块,用于检测按键事件,按钮被释放后自动恢复到常态。
- 在按钮未被按下时模块输出高电平,按钮被按下后输出低电平。
- http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Button/zh
- http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Buzzer/zh
- https://item.taobao.com/item.htm?spm=a1z10.1-c.w4004-7494828559.5.XnK9o0&id=544520132488
- 准备好器材,NanoPi NEO,NanoHat Hub扩展板,无源蜂鸣器模块,按键模块,串口转接板,class10 sd卡,定制排线
import bakebitimport time# Connect the BakeBit Ultrasonic Ranger to digital port D4# SIG,NC,VCC,GNDultrasonic_ranger = 4 # Connect the BakeBit LED to digital port D3led = 3 bakebit.pinMode(led,"OUTPUT")light = 0 while True: try: # Read distance value from Ultrasonic distance = bakebit.ultrasonicRead(ultrasonic_ranger) print(distance)if distance > 0: if distance<10: if light == 0: print("\ton") bakebit.digitalWrite(led,1) light = 1 else: if light == 1: print("\toff") bakebit.digitalWrite(led,0) light = 0 time.sleep(.2) except KeyboardInterrupt: bakebit.digitalWrite(led,0) break except TypeError: print ("Error") except IOError: print ("Error")
|