WiringPi ODROID C2 Python 读取模拟输入
WiringPi ODROID C2 Python reading analogue input
ODROID C2是一款类似于Raspberry PI的开发板。我已经按照网站为我的开发板指定的方式安装和配置了 WiringPi。 运行 gpio readall
returns table:
+------+-----+----------+------+ Model ODROID-C2 +------+----------+-----+------+
| GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| | 8 | SDA.1 | | | 3 || 4 | | | 5V | | |
| | 9 | SCL.1 | | | 5 || 6 | | | 0v | | |
| 249 | 7 | GPIO.249 | IN | 1 | 7 || 8 | | | TxD1 | 15 | |
| | | 0v | | | 9 || 10 | | | RxD1 | 16 | |
| 247 | 0 | GPIO.247 | IN | 1 | 11 || 12 | 1 | IN | GPIO.238 | 1 | 238 |
| 239 | 2 | GPIO.239 | IN | 1 | 13 || 14 | | | 0v | | |
| 237 | 3 | GPIO.237 | IN | 1 | 15 || 16 | 1 | IN | GPIO.236 | 4 | 236 |
| | | 3.3v | | | 17 || 18 | 1 | IN | GPIO.233 | 5 | 233 |
| 235 | 12 | GPIO.235 | IN | 1 | 19 || 20 | | | 0v | | |
| 232 | 13 | GPIO.232 | IN | 1 | 21 || 22 | 1 | IN | GPIO.231 | 6 | 231 |
| 230 | 14 | GPIO.230 | IN | 1 | 23 || 24 | 1 | IN | GPIO.229 | 10 | 229 |
| | | 0v | | | 25 || 26 | 1 | OUT | GPIO.225 | 11 | 225 |
| | 30 | SDA.2 | | | 27 || 28 | | | SCL.2 | 31 | |
| 228 | 21 | GPIO.228 | IN | 1 | 29 || 30 | | | 0v | | |
| 219 | 22 | GPIO.219 | IN | 1 | 31 || 32 | 1 | IN | GPIO.224 | 26 | 224 |
| 234 | 23 | GPIO.234 | IN | 0 | 33 || 34 | | | 0v | | |
| 214 | 24 | GPIO.214 | IN | 1 | 35 || 36 | 1 | IN | GPIO.218 | 27 | 218 |
| | 25 | AIN.1 | | | 37 || 38 | | | 1v8 | 28 | |
| | | 0v | | | 39 || 40 | | | AIN.0 | 29 | |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
我正在尝试从接线 pi 列(左下数第二个)的模拟引脚 #25 读取输入。
脚本代码如下:
#!/usr/bin/python
import wiringpi2 as wpi
import time
wpi.wiringPiSetup()
while True:
print(wpi.analogRead(25))
#use pin 25 for analogue input
为什么只返回 0?我的 phone 通过辅助接头连接到模拟引脚。左右音频线拼接在一起并连接到 wiringpi pin #25。
我已确认 wiringpi 正在运行。我能够控制 LED。用示波器确认电路工作正常。
感谢您的帮助。
ODROID 论坛上的一个回答详细说明了引脚似乎是按引脚类型寻址的。由于 ODROID C2 只有两个模拟输入引脚,因此它们分别被指定为引脚 #0 和 #1。将引脚号更改为 #1 解决了问题(后来我将模拟输入引脚移到了接头的另一侧)。
ODROID C2是一款类似于Raspberry PI的开发板。我已经按照网站为我的开发板指定的方式安装和配置了 WiringPi。 运行 gpio readall
returns table:
+------+-----+----------+------+ Model ODROID-C2 +------+----------+-----+------+
| GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| | 8 | SDA.1 | | | 3 || 4 | | | 5V | | |
| | 9 | SCL.1 | | | 5 || 6 | | | 0v | | |
| 249 | 7 | GPIO.249 | IN | 1 | 7 || 8 | | | TxD1 | 15 | |
| | | 0v | | | 9 || 10 | | | RxD1 | 16 | |
| 247 | 0 | GPIO.247 | IN | 1 | 11 || 12 | 1 | IN | GPIO.238 | 1 | 238 |
| 239 | 2 | GPIO.239 | IN | 1 | 13 || 14 | | | 0v | | |
| 237 | 3 | GPIO.237 | IN | 1 | 15 || 16 | 1 | IN | GPIO.236 | 4 | 236 |
| | | 3.3v | | | 17 || 18 | 1 | IN | GPIO.233 | 5 | 233 |
| 235 | 12 | GPIO.235 | IN | 1 | 19 || 20 | | | 0v | | |
| 232 | 13 | GPIO.232 | IN | 1 | 21 || 22 | 1 | IN | GPIO.231 | 6 | 231 |
| 230 | 14 | GPIO.230 | IN | 1 | 23 || 24 | 1 | IN | GPIO.229 | 10 | 229 |
| | | 0v | | | 25 || 26 | 1 | OUT | GPIO.225 | 11 | 225 |
| | 30 | SDA.2 | | | 27 || 28 | | | SCL.2 | 31 | |
| 228 | 21 | GPIO.228 | IN | 1 | 29 || 30 | | | 0v | | |
| 219 | 22 | GPIO.219 | IN | 1 | 31 || 32 | 1 | IN | GPIO.224 | 26 | 224 |
| 234 | 23 | GPIO.234 | IN | 0 | 33 || 34 | | | 0v | | |
| 214 | 24 | GPIO.214 | IN | 1 | 35 || 36 | 1 | IN | GPIO.218 | 27 | 218 |
| | 25 | AIN.1 | | | 37 || 38 | | | 1v8 | 28 | |
| | | 0v | | | 39 || 40 | | | AIN.0 | 29 | |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
我正在尝试从接线 pi 列(左下数第二个)的模拟引脚 #25 读取输入。
脚本代码如下:
#!/usr/bin/python
import wiringpi2 as wpi
import time
wpi.wiringPiSetup()
while True:
print(wpi.analogRead(25))
#use pin 25 for analogue input
为什么只返回 0?我的 phone 通过辅助接头连接到模拟引脚。左右音频线拼接在一起并连接到 wiringpi pin #25。
我已确认 wiringpi 正在运行。我能够控制 LED。用示波器确认电路工作正常。
感谢您的帮助。
ODROID 论坛上的一个回答详细说明了引脚似乎是按引脚类型寻址的。由于 ODROID C2 只有两个模拟输入引脚,因此它们分别被指定为引脚 #0 和 #1。将引脚号更改为 #1 解决了问题(后来我将模拟输入引脚移到了接头的另一侧)。