Raspberry精要
来自Jack's Lab
(版本间的差异)
(→树莓派精要) |
(→树莓派精要) |
||
第1行: | 第1行: | ||
== 树莓派精要 == | == 树莓派精要 == | ||
− | + | [[文件:Raspberry-pi-pinout.png|right]] | |
第7行: | 第7行: | ||
右图所示为Pi2,Pi3引脚的BCM定义 | 右图所示为Pi2,Pi3引脚的BCM定义 | ||
− | |||
==修改VNC链接分辨率== | ==修改VNC链接分辨率== |
2017年11月7日 (二) 21:42的版本
目录 |
1 树莓派精要
Raspberry 树莓派各个版本的引脚定义
右图所示为Pi2,Pi3引脚的BCM定义
2 修改VNC链接分辨率
vncserver -geometry 1280x800 -depth 16 #命令运行完毕给出一个编号, VNCview内用这个编号连接即可,如果返回1则 vncviewer 192.168.1.209:1
3 GPIO
在命令行的工具gpio是很有用的一个工具。给出了各种命名的映射关系。
gpio 命令所采用的命名规范是Name一列的名字
常见扩展板的多采用BCM命名规范
python库RPi.GPIO 则直接采用Physical引脚编号。
4 树莓派LED blink
将一个led串接330欧姆电阻,接物理引脚(就是2x40排针)的11脚(GPIO.0, BCM P17)和3脚(GND)
直接采用gpio命令
gpio mode GPIO.0 out gpio write GPIO.0 1 gpio write GPIO.0 0 gpio blink GPIO.0
采用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()