查看Raspberry精要的源代码
←
Raspberry精要
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
==树莓派LED blink== [[文件:Led-blink.png|top|480px]] 将一个led串接330欧姆电阻,接物理引脚(就是2x40排针)的11脚(GPIO.0, BCM P17)和3脚(GND) 直接采用gpio命令 <source lang=bash> gpio mode GPIO.0 out gpio write GPIO.0 1 gpio write GPIO.0 0 gpio blink GPIO.0 </source> 采用python <source lang=python> import RPi.GPIO as GPIO import time LedPin = 11 # pin11 def setup(): GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's mode is output GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to turn on led def blink(): while True: GPIO.output(LedPin, GPIO.LOW) # led on time.sleep(0.5) GPIO.output(LedPin, GPIO.HIGH) # led off time.sleep(0.5) def destroy(): GPIO.output(LedPin, GPIO.LOW) # led off GPIO.cleanup() # Release resource if __name__ == '__main__': # Program start from here setup() try: blink() except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed. destroy() </source>
返回到
Raspberry精要
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面