Blinking an LED with an Arduino and pySerial


Question

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. 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. Can anyone point me to a location with this example or show me how it's done?

1
5
2/11/2013 5:26:39 AM

Accepted Answer

The official page on interfacing Arduino with Python is here:

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

If you need a "real" example you might want to have a look at my VU meter experiment. I use python to push the volume data into the Arduino. Nothing fancy but it should give you an idea.

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

4
2/11/2013 7:42:34 AM

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. There are programs like Firmata that will do this for you (or Firmata and 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.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon