So today I spent a big chunk of the day playing around in python. I've been interested in it ever since the Kindle Weather Display project. It has a pretty easy to read syntax and seems like it would be great for manipulating data from the arduino and graphing.
The first step is getting communication working.
I hooked up a temperature sensor, installed PySerial, a module for serial communication in python, and plugged in the arduino. For the arduino, I used the sketch in the Ladyada program for DHT11.
The program in python was more simple than I thought. Here's all I did:
import serial
arduino = 'COM7'
ser = serial.Serial('COM7', 9600)
for x in range (0,3):
print ser.readline()
(x)
And as you can see everything worked out pretty easily. The program will print 3 lines from the arduino and then stop.
In case you're wondering, that shield on the arduino is the OpenSourceRF wireless shield. It wasn't actually doing anything, but I was too lazy to pull it off.
No comments:
Post a Comment