xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Raspberry Pi & Python & GPIO All In One

Raspberry Pi & Python & GPIO All In One

RPi.GPIO

RPi.GPIO 0.7.1

$ pip install RPi.GPIO

A Python module to control the GPIO on a Raspberry Pi

https://pypi.org/project/RPi.GPIO/

arduino

https://www.arduino.cc/

$ sudo apt-get update

# install the RPi.GPIO package
$ sudo apt-get install rpi.gpio

https://www.raspberrypi-spy.co.uk/2012/05/install-rpi-gpio-python-library/

GPIO

GPIO 12 / BCM 12

Physical/Board pin 32
GPIO/BCM pin 12
Wiring Pi pin 26

物理/电路板引脚 32 ✅
GPIO/BCM 引脚 12 ✅
接线 Pi 引脚 26

image

https://pinout.xyz/pinout/pin32_gpio12

pinout

$ pinout

GPIO 图解

https://www.raspberrypi.com/software

https://www.raspberrypi.com/documentation/computers/os.html#gpio-and-the-40-pin-header

image

image

image

pdfs

https://github.com/raspberrypipress/released-pdfs/

https://raw.githubusercontent.com/raspberrypipress/released-pdfs/main/simple-electronics-with-gpio-zero.pdf

from gpiozero import LED
from time import sleep
red = LED(25)
amber = LED(8)
green = LED(7)
green.on()
amber.off()
red.off()
while True:
  sleep(10)
  green.off()
  amber.on()
  sleep(1)
  amber.off()
  red.on()
  sleep(10)
  amber.on()
  sleep(1)
  green.on()
  amber.off()
  red.off()

image

???

https://stackoverflow.com/questions/44113851/import-rpi-gpio-as-gpio-importerror-no-module-rpi

#import the GPIO and time package
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
# loop through 50 times, on/off for 1 second
for i in range(50):
    GPIO.output(7,True)
    time.sleep(1)
    GPIO.output(7,False)
    time.sleep(1)
GPIO.cleanup()

https://pimylifeup.com/raspberry-pi-gpio/

demos

import RPi.GPIO as GPIO

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://github.com/raspberrypipress/released-pdfs/

https://www.cnblogs.com/xgqfrms/p/17261187.html#5162198



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-03-27 23:58  xgqfrms  阅读(35)  评论(4编辑  收藏  举报