Saturday, March 28, 2009

Arduino Library for Processing

I have already done some work with Arduino and C#.NET in an earlier post and now decided to extend the work to Java as well with the Processing software. For example, at http://www.arduino.cc/playground/Interfacing/Processing they provide the following Processing code:

import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
void setup()
{
//
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0]);
// v2
//
arduino = new Arduino(this, Arduino.list()[0], 57600);
// v1
arduino.pinMode(ledPin, Arduino.OUTPUT);
}
void draw()
{
arduino.digitalWrite(ledPin, Arduino.HIGH);
delay(1000);
arduino.digitalWrite(ledPin, Arduino.LOW);
delay(1000);
}

that can be exported to an executable jar. Futhermore, the provide the Arduino jar and source code to control the board from Processing. A nice vehicle for getting up to speed quickly with Arduino applications. For other languages beside Java and C#, refer to http://www.arduino.cc/playground/Main/InterfacingWithSoftware .

No comments: