Reputation: 21904
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?
Upvotes: 5
Views: 14509
Reputation: 69172
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.
Upvotes: 4
Reputation: 6882
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/
Upvotes: 4