简体   繁体   English

使用Arduino和pySerial闪烁LED

[英]Blinking an LED with an Arduino and pySerial

I feel really silly for asking this, but I've been shocked at my inability to find the simplest example I can imagine for talking to an Arduino over Serial. 我觉得这个问题真的很傻,但是我很震惊我无法找到一个我能想象的最简单的例子来与Arduino进行交谈。 I have a connection set up, and I understand how to write both Arduino Code and Python, but I have no idea how to write to an arduino pin using python. 我有一个连接设置,我知道如何编写Arduino代码和Python,但我不知道如何使用python写入arduino引脚。 Can anyone point me to a location with this example or show me how it's done? 任何人都可以通过这个例子向我指出一个位置或者告诉我它是如何完成的吗?

There isn't a direct way to control the Arduino through the serial port, so you would need to have some program running on the Arduino that could respond to serial information and do what you want. 没有通过串口控制Arduino的直接方法,因此您需要在Arduino上运行一些可以响应串行信息并执行您想要的程序。 There are programs like Firmata that will do this for you (or Firmata and Pyduino ). Firmata这样的程序会为你(或Firmata和Pyduino )做这个。 Or you could write your own sketch and put it on the Arduino, that waits for a certain serial symbol and sets the pin accordingly. 或者您可以编写自己的草图并将其放在Arduino上,等待某个序列符号并相应地设置引脚。

The official page on interfacing Arduino with Python is here: 关于Arduino与Python接口的官方页面如下:

http://playground.arduino.cc/interfacing/python http://playground.arduino.cc/interfacing/python

If you need a "real" example you might want to have a look at my VU meter experiment. 如果你需要一个“真实”的例子,你可能想看看我的VU表实验。 I use python to push the volume data into the Arduino. 我使用python将卷数据推送到Arduino。 Nothing fancy but it should give you an idea. 没有什么花哨但它应该给你一个想法。

http://blog.blinkenlight.net/experiments/basic-effects/vu-meter/ http://blog.blinkenlight.net/experiments/basic-effects/vu-meter/

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

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