我有一个python脚本,可以像我想要的那样设置Raspberry Pi 3的输出(一个led控制器)。但是3个引脚总是在默认设置1上,我不能将它们设置为0.我不知道为什么。
我试着设置它们"手册"低但它不会工作 console:gpio写引脚0
我查看了目录/ modules,如果sth保留了引脚但是列表是空的。(可能是服务吗?,但是如果是的那个?)
我写了一个.sh和.bash脚本,在启动时将它们再次设置为0,但它也没有用。
我停用了接口中的所有内容 - raspi-config,希望它使用pin。(而不是ssh)失败。
我找到了数据表 https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf第102页
在那里你可以看到一个引脚的功能。我必须改变它们吗?
我需要使用我的所有引脚。(0到27)
pi@pi3:~ $ gpio readall
+-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | OUT | 0 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | OUT | 0 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | OUT | 0 | 7 || 8 | 0 | OUT | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 0 | OUT | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | OUT | 1 | 11 || 12 | 1 | OUT | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | OUT | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | OUT | 0 | 15 || 16 | 0 | OUT | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | OUT | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | OUT | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | OUT | 0 | 21 || 22 | 0 | OUT | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | OUT | 0 | 23 || 24 | 0 | OUT | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 0 | OUT | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | OUT | 0 | 27 || 28 | 0 | OUT | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | OUT | 0 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | OUT | 0 | 31 || 32 | 0 | OUT | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | OUT | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | OUT | 0 | 35 || 36 | 1 | OUT | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | OUT | 0 | 37 || 38 | 0 | OUT | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | OUT | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
pi@pi3:~ $ gpio write GPIO.0 0
pi@pi3:~ $ gpio write GPIO.1 0
pi@pi3:~ $ gpio write GPIO.27 0
pi@pi3:~ $ gpio readall
+-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | OUT | 0 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | OUT | 0 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | OUT | 0 | 7 || 8 | 0 | OUT | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 0 | OUT | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | OUT | 1 | 11 || 12 | 1 | OUT | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | OUT | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | OUT | 0 | 15 || 16 | 0 | OUT | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | OUT | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | OUT | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | OUT | 0 | 21 || 22 | 0 | OUT | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | OUT | 0 | 23 || 24 | 0 | OUT | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 0 | OUT | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | OUT | 0 | 27 || 28 | 0 | OUT | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | OUT | 0 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | OUT | 0 | 31 || 32 | 0 | OUT | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | OUT | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | OUT | 0 | 35 || 36 | 1 | OUT | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | OUT | 0 | 37 || 38 | 0 | OUT | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | OUT | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
我没有想法。 我希望我的英语能够很好地理解我的问题。 问候。
答案 0 :(得分:0)
通电的引脚是由pi拉高的引脚。这意味着引脚通常为高而不是低。
您链接到的pdf将gpio引脚称为BCM
模式。
如果你查看输出,那么通电的引脚(在BCM模式下) 是16,17和18。
查看手册,它说gpio 16和17的功能都是保留的。
Gpio 18,但如果我没记错的话, 可以 拉低。 我依稀记得必须将一个引脚置为低电平接收器。
我现在不在我的pi附近,但我相信你可以像这样把gpio 18带到低位:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)
GPIO.output(18, False)