问题描述
我想将Vandal Switch(cps)与RaspBerry Pi连接起来,在那里我想在按下按钮时通过Phython程序进行注册,并将Led灯从蓝色更改为红色。
我如何将电缆连接到RaspBerry Pi:
-
brown cable -> 5V Power
-
Black cable -> Ground
-
Black cable -> Ground
-
white cable 1 -> GPIO5
-
White cable 2 -> GPIO6
-
Green cable (green LED) -> GPIO2
-
Blue cable (blue LED) -> GPIO3
-
Red cable (red LED) -> GPIO4
我在RaspBerry Pi的phyton上尝试过此操作:
from gpiozero import Button,LED
from signal import pause
led = LED(3)
button = Button(5)
button.when_pressed = led.on
button.when_pressed = led.off
pause()
错误:没有名为“ gpiozero”的模块
我已经通过控制台命令安装了模块:
sudo apt update
sudo apt install phyton-gpiozero
(它说它已经是最新版本了)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)