Raspberry Pi

- 3 mins

1-Wire Bus

DATE: 2018-03-29


树莓派中文环境配置

参考文献:http://shumeipai.nxez.com/2016/03/13/how-to-make-raspberry-pi-display-chinese.html

  1. 安装中文字体:

    sudo apt-get install ttf-wqy-zenhei

  2. 安装中文输入法:

    sudo apt-get install scim-pinyin

  3. 修改树莓派配置:

    sudo raspi-config

    在change_locale中选择zh_CN.UTF-8

  4. 重启后即可

DATE: 2018-03-30

参考文献:http://shumeipai.nxez.com/2015/03/11/raspberry-pi-to-install-chinese-input-method-fcitx-and-google-pinyin-ime.html

  1. 安装fcitx输入法:

    sudo apt-get install fcitx

  2. 下载google拼音支持:

    sudo apt-get install fcitx-googlepinyin


修改用户密码

参考文献:https://blog.csdn.net/guanmaoming/article/details/78760428

  1. 修改pi用户密码

    sudo passwd pi

  2. 修改root用户密码

    sudo passwd root

  3. 用户切换

    su root

    su pi


修改镜像源

参考文献:https://blog.csdn.net/la9998372/article/details/77886806

  1. 使用管理员权限编辑/etc/apt/sources.list文件:

    sudo vim /etc/apt/sources.list

  2. #注释掉原来的内容,写入以下内容:

    deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    
  3. 使用管理员权限编辑/etc/apt/sources.list.d/raspi.list文件:

    sudo vim /etc/apt/sources.list.d/raspi.list

  4. #注释掉原来的内容,写入以下内容:

    deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
    deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
    
  5. 更新软件源列表:

    sudo apt-get update


需要安装的包

  1. vim
  2. lftp
  3. curl
  4. ctags

DATE: 2018-05-22


python包安装:pip install [package]

python帮助文档:pydoc [package]

RPi.GPIO

参考文献:RPi.GPIO的wiki:https://sourceforge.net/p/raspberry-gpio-python/wiki/Home/

图片来源:RPi.Pinout:https://blog.csdn.net/coder9999/article/details/76904625

Demo Code

Instructions List

Importing the module

# To import the RPi.GPIO module:
import RPi.GPIO as GPIO

# To import the module and check to see if it is successful:
try:
    import RPi.GPIO as GPIO
except RuntimeError:
    print("Error importing RPi.GPIO!  This is probably because you need superuser privileges.  You can achieve this by using 'sudo' to run your script")

Pin numbering

# To set the numbering system:
GPIO.setmode(GPIO.BOARD)
GPIO.setmode(GPIO.BCM)

# To detect the numbering system:
mode = GPIO.getmode()

RPi_pinout

If you are confused about the numbers of these systems, you can use gpio readall in terminal to show it like this:

GPIO_readall

Warnings

# To disable warnings while more than one script/circuit on the GPIO of RPi:
GPIO.setwarnings(False)

Setup channel(s)

# [channel] depends on the numbering system you choose
	
# To configure a channel as an input:
GPIO.setup([channel], GPIO.IN)

# To set up a channel as an output:
GPIO.setup([channel], GPIO.OUT)
	
# Specify an initial value of output channel:
GPIO.setup([channel], GPIO.OUT, initial=GPIO.HIGH)
	
# Set up more than one channel per call:
chan_list = [11, 12]  # You can tuples instead
GPIO.setup(chan_list, GPIO.OUT)

Input & Output

# To read the value of a GPIO pin:
GPIO.input([channel])

# TO set the output state of a GPIO pin:
GPIO.output([channel], [state])

# State can be 0/GPIO.LOW/False or 1/GPIO.HIGH/True

# Output to several channels
chan_list = [11, 12]
GPIO.output(chan_list, GPIO.LOW)  # Set all to GPIO.LOW
GPIO.output(chan_list, (GPIO.HIGH, GPIO.LOW))  # Set first HIGH and second LOW

Cleanup

# It is good practice to clean up any resources you might have used. By returning all channels you have used back to inputs with no pull up/down, you can avoid accidental damage to your RPi by shorting out the pins. Note that this will only clean up GPIO channels that your script has used. Note that GPIO.cleanup() also clears the pin numbering system in use.
# To clean up channels you used at the end of script:
GPIO.cleanup()

# Clean up individual channels, a list or a tuple of channels:
GPIO.cleanup([channel])
GPIO.cleanup((channel1, channel2))
GPIO.cleanup([channel1, channel2])
Kaixin Yang

Kaixin Yang

做你该做的事情,并接受它的事与愿违

rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora