简体   繁体   English

模拟Raspberry Pi GPIO信号

[英]Simulate Raspberry Pi GPIO signal

I'm new on Raspberry Pi and I would to know how can we simulate/mock the sensors (or GPIO) so I can test just my python code, mocking the Highs and Lows of the pins? 我是Raspberry Pi的新手,我想知道我们如何模拟/模拟传感器(或GPIO),这样我就可以测试我的python代码,模拟引脚的高点和低点?

Thanks in advance! 提前致谢!

IF you just don't want to trust a software layer, you could try manually setting the pin high: 如果您不想信任软件层,可以尝试手动将引脚设置为高:

The GPIO pins on the Raspberry Pi work with a voltage of 3.3VDC. Raspberry Pi上的GPIO引脚工作电压为3.3VDC。

Pins 1 & 17 on the P1-GPIO header outputs 3.3VDC. P1-GPIO接头上的引脚1和17输出3.3VDC。

You could CAREFULLY try to connect a jumper from Pin 1 or 17 to the GPIO input pin you want to test. 您可以小心地尝试将引脚1或17的跳线连接到要测试的GPIO输入引脚。 Connect it to test high, disconnect to test for low. 将其连接至测试高电平,断开连接以测试低电平。

MAKE SURE YOU DON"T USE THE 5VDC GPIO PINS, YOU COULD/WILL DAMAGE/KILL YOUR PI! 请确保您“不使用5VDC GPIO PIN,您可能会/会损坏/杀死您的PI!

I've made a RPi GPIO simulator to allow you to quickly test python scripts in a web browser. 我已经制作了一个RPi GPIO模拟器,允许您在Web浏览器中快速测试python脚本。

Here's an example for flashing an output pin: https://create.withcode.uk/python/A5 以下是闪烁输出引脚的示例: https//create.withcode.uk/python/A5

Alternatively, there's a library that you could download to simulate the inputs / outputs offline: 或者,您可以下载一个库来离线模拟输入/输出:

https://roderickvella.wordpress.com/2016/06/28/raspberry-pi-gpio-emulator/ https://roderickvella.wordpress.com/2016/06/28/raspberry-pi-gpio-emulator/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM