views:

943

answers:

6

I am starting to get a bit bored of programming little toys that I have been making recently, and I would love to starting programming and interacting with hardware.

The only problem is that I am mostly a python guy who hasn't really learned or used any other language. Can I still interact with hardware with python?

Also, what hardware can I interact with? I don't really have stuff lying around that I can use, so I would have to buy a kit or something. What are some cheap options for this?

+3  A: 

try BugLab or OpenMoko

oykuo
"What are some cheap options for this?" Buying a phone is not cheap
joshhunt
+8  A: 

Interacting with the serial port on a PC is fairly trivial and there is Python Serial library available. The roomba robot is controllable via a serial port. There are probably other robots out there, but this might be a simple, smallish step to get you going.

Personally, I learned a lot by buying a PIC programmer and making some simple circuits to flash LEDs. I moved on to controlling those PICs via serial port and later using USB (via libusb). There's a bigger learning curve there as you'll have to program the PICs in C or assembler but you can achieve some pretty incredible results once you've picked up the basics. I warn you though, it's a slippery slope once you realise how many cool little gadgets you can build :-)

Jon Cage
pySerial is fantastic (and refreshingly cross-platform); I've been using it to communicate with the ECU in my car (embedded on-board computer, basically; SuperH architecture) to perform flashing and logging, and it works like a champ. If you're working with more modern hardware without a native serial port, FTDI (http://www.ftdichip.com/) serial-to-usb devices are quite handy; while you can still use pySerial to talk to them, you can also use libftdi (http://www.intra2net.com/en/developer/libftdi/), whose SWIG interface gives a somewhat richer API.
esm
+1 for the microcontroller idea. It is a good way to start lowlevel in an environment that is still overseeable.
Marco van de Voort
+2  A: 

You can use ctypes for interfacing with hardware. It'll let you call into native libraries, so you can essentially use it to do anything that C can do. This is of course assuming that you want to interact with hardware via your host computer running Python.

I've used ctypes for a couple of projects:

I found it generally pretty easy to use, but it helped that I already knew C/C++.

John Montgomery
+2  A: 

Buy a Lego Mindstorm kit. The programming language is easy to live with -- it isn't Python -- but it's close enough. And they're real robots with real actuators and sensors.

S.Lott
+6  A: 

Definitely look at Arduino.

  • The hardware design is open-source so you could even assemble your own if you wanted.
  • The board includes digital and analogue inputs and outputs so it's easy to get some LEDs flashing quickly.
  • You program it in a 'language' called Wiring which hides a lot of complexities of C which is usually used on PICs.

On the PC side, you could then use pySerial to communicate with the board over USB as mentioned above

pufferfish
+1: For the mention of Arduino. I was trying to think of the name earlier and couldn't remember it. I've often toyed with the idea of having a go with one though :-)
Jon Cage
+2  A: 

Many pc's still have parellel ports, and a python module exists for interacting with the parallel port, though I haven't used it.

The parallel port may be the simplest way to start controlling hardware, as you can attach the simplest of electronics to it. Just an led will get you something visible straight away.

Then, as Jon Cage mentions, you could get a Pic programmer

David Sykes
+1: You're right, the parallel port is probably simpler to get started with.
Jon Cage