On Feb 21, 11:28 pm, Simon Ward <[email protected]> wrote:
> Madlab are running the “Omniversity of Manchester” and have some Arduino
> courses[1][2] on the go, in case anybody is intersted.
>
> There are some Python libraries for Arduino magic, but I haven’t used
> them yet.  I’d love to hear how people get on with them.

Using arduino and python is pretty simple, primarily because the
arduino itself is simple. For those that don't know, with ardunio,
you:

1. Build a circuit, and plug it into various ports on the board
2. You then write a small program in a derivative of C using  the
arduino dev kit, compile it and upload it over USB to the arduino.
(It's just a small computer really, with a large number of digital &
analogue IO pins).
3. The code on the arduino can switch on/off digital pins, read values
from digital pins, and similar for the analogue pins.
4. The arduino can send messages up a USB cable to another computer.
5. The host computer sees the arduino as a serial device.

So from the python side, your code can look like this:

ser = serial.Serial('/dev/ttyUSB0', 9600)
ser.write("p 1")
ser.write("f 100")
ser.write("r 90")
ser.write("f 100")
ser.write("r 90")
ser.write("f 100")
ser.write("r 90")
ser.write("f 100")
ser.write("r 90")
ser.write("p 0")

Something I hacked together for a colleague a while back is here:
http://code.google.com/p/kamaelia/source/browse/trunk/Sketches/MPS/ArduinoRelated/ArdBot.py

Which is a very simple/hacky robot control program.

This is slightly more interesting:
http://code.google.com/p/kamaelia/source/browse/trunk/Sketches/MPS/ArduinoRelated/ArdPlay.py

Because that's an arduino controlled slideshow/presentation tool.
(Advances when someone causes an analogue sensor's threshold to change
- eg a light covering an LDR)

The arduino code that runs on the arduino for the latter looks like
this:
http://code.google.com/p/kamaelia/source/browse/trunk/Sketches/MPS/ArduinoRelated/arduinocode/AnalogInputWithSerial/AnalogInputWithSerial.pde

Which as you can see is equally simple. (Little things sending
messages between them)


Michael.

-- 
To post: [email protected]
To unsubscribe: [email protected]
Feeds: http://groups.google.com/group/python-north-west/feeds
More options: http://groups.google.com/group/python-north-west

Reply via email to