pi@raspberrypi:~ $ gpio -v gpio version: 2.50 Copyright (c) 2012-2018 Gordon Henderson This is free software with ABSOLUTELY NO WARRANTY. For details type: gpio -warranty
Raspberry Pi Details: Type: Unknown17, Revision: 01, Memory: 0MB, Maker: Sony * Device tree is enabled. *–> Raspberry Pi 4 Model B Rev 1.1 * This Raspberry Pi supports user-level GPIO access. pi@raspberrypi:~ $ gpio readall Oops – unable to determine board type… model: 17 2:问题是wiringPi版本为识别树莓派4B版本类型;需要按照官网指引升级版本如下:
打开树莓派终端输入:
cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb 然后再:
Raspberry Pi Compute Module 4(CM4)模块是基于Raspberry Pi 4 Model B性能的产品,但其外形尺寸较小,非常适合嵌入到没有大量经典Raspberry Pi的产品或项目中。对于深度嵌入的应用程序,您可以以紧凑的形式获得Raspberry Pi 4的所有计算能力。CM4采用了相同的四核ARM Cortex-A72处理器、双视频输出、千兆以太网、UART、I2C、SPI、I2S和一些PWM。
本产品Raspi Compute Stick是基于Raspberry Pi CM4的扩展板底板。为CM4模块提供多种扩展接口,包括升级接口、GPIO扩展、CSI、HDMI、TF、USB、风扇等等,并且扩展底板尺寸小巧轻薄可适应更多使用场景。
注:通电前请确认CM4模块正确的安装在扩展板上
产品特性
§ 树莓派CM4模块接口
§ 1 x 全尺寸 HDMI 2.0 接口
§ 1x USB-A: OTG USB(用于升级更新Compute Module 4模块)
§ 1x USB-AF: USB 2.0 High Speed接口
§ 1x USB-C: Type-c电源接口 5V/3A
§ TF Card接口: microSD卡插槽 (只支持不包含eMMC的CM4模块)
§ GPIO: 20Pin GPIO扩展接口(定义见丝印标)
§ 1x 风扇接口r: 4P/1.25mm PWM风扇控制接口
§ 1 x CSI 摄像头 FPC connectors (22-pin 0.5 mm pitch cable)
#deb-src http://archive.raspberrypi.org/debian/ stretch main
deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi
sudo pip install rpi.gpio // install RPi.GPIO library
nano button.py // copy the following code in button.py
编辑button.py文件,添加以下代码并保存
import RPi.GPIO as GPIO
import time
BUTTON = 6
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)
while True:
state = GPIO.input(BUTTON)
if state:
print("off")
else:
print("on")
time.sleep(1)
运行程序后,可以从打印中看到按键的状态
pi@raspberrypi:~ $ python button.py
off
off
on
on
off
#deb-src http://archive.raspberrypi.org/debian/ stretch main
deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi