Raspberry精要

来自Jack's Lab
2017年11月7日 (二) 21:37Hyl (讨论 | 贡献)的版本

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转到: 导航, 搜索

目录

1 树莓派精要

Raspberry 树莓派各个版本的引脚定义


2 修改VNC链接分辨率

vncserver -geometry 1280x800 -depth 16

#命令运行完毕给出一个编号, VNCview内用这个编号连接即可,如果返回1则
vncviewer 192.168.1.209:1


3 GPIO

Gpio-readall.JPG

在命令行的工具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()

5 树莓派典型项目攻略

树莓派实战GPRS

个人工具
名字空间

变换
操作
导航
工具箱