arduino: December 2008 Archives

Today I spent the day at the Protospace FabLab in Utrecht. Not that I really had something to make there, but being at that location meant I was focussed on doing something related to personal fabrication and Arduino, and not get distracted by other things around our house.

My main goal to start with was to get my Arduino board to send data to Processing. This way you can build applications around data that is coming from the Arduino board, or have apps send data to the Arduino.

Basically what you do is load the Arduino with a Fermata script that continuously reads/writes the Arduino's digital and analog in/outputs. Then in Processing you actually create your script (which you otherwise would create in the Arduino software tool).

First you need to make sure that the right libraries are available to both Arduino and Processing. Good instructions for this are on the Arduino website.

With the Arduino board I created a simple circuit with a temperature sensitive resistor connected to an analog input, so that with changing temperature the reading of that temperature would change.

I loaded the Arduino board with the Simple_Analog_Firmata script (the other Analog_Firmata I could not get to work properly yet). Simple_Analog_Firmata is part of the Library_Firmata library, and should be available under Open, Examples.

Then in Processing I loaded arduino_input from Libraries, Arduino, Examples.
The example script reads all digital and analog input ports of the Arduino, but I only needed the analog one that was connected to the thermistor. So I simplified the setup() routine by deleting the initialisation for the 13 digital inputs, and simplified the draw() routine to:

void draw() {
background(off);
stroke(on);
fill(on);

ellipse(235, 140, (arduino.analogRead(2)-300), 20);
}

This little statement draws an ellipse with the value from analog port 2 on the Arduino as the horizontal radius. I substracted 300 from the Arduino reading, as that brought the value within a range that was easy to draw. I kept the vertical radius constant, so I could see a vertical line even when there was no reading from the Arduino. Then I ran the Processing script.

Now when I touched the thermistor (causing its temperature to rise, and its value to fall) the ellipse's horizontal radius became smaller. How pleased can you be with a small blue ellipse on your screen? Very! :)

Processing using Arduino input data
Screenshot of the ellipse

Screenshot at higher temperature
At higher temperature the ellipse becomes smaller

Technorati Tags: ,


About this Archive

This page is a archive of entries in the arduino category from December 2008.

arduino: October 2008 is the previous archive.

arduino: June 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.

arduino: December 2008: Monthly Archives

Powered by Movable Type 4.0