Thursday, December 27, 2007

First Ardunio Program

I have finally received my Arduino and have been able to write a few simple programs for it. For my thermostat program I am interested in being able to read several analog sensors (temperature and humidity). I also need to be able to poll specific sensor values from the computer using the serial interface so I can log their values in 5 minute intervals. I don't have all the electronic components yet to build my thermostat so I wanted to write up some test sketches. I based my sketches on a todbot blog entry that I found very useful.

I was originally going to use the C code that todbot wrote to test communication with the Arduino but I soon realized the limitations. What I ended up doing is using "screen" to open a terminal connection to the serial port so I could send and receive data to/from the Arduino. In the future I will have to write a daemon that will run on my linux box that will constantly poll the Arduino for data but thats another story. For now screen will work.

Download serial_tty.pde for the source code.


Using Screen


On my Mac all I had to type to communicate with my Arduino running the above sketch was:


screen /dev/cu.usbserial 9600

To "kill" your screen session you have to type: ctrl+a k


Hope you enjoy. I'm out.

No comments:

Twittering from the linux command line using curl

Recently I signed up for twitter and have found the need to "twit" from the command line. I found a quick tutorial on how to use ...