Control Arduino digital pin using a shell script

Hi , i recently purchased the arduino UNO.. and i've been playing a lot with it.. I want to be able to set HIGH or LOW a digital pin (say pin 2 ) by running a shell script or say a java code. So say i have this shell script which turns digital pin 13 on when the script is executed.. is there a way to do this? if not shell script , is it possible to do it using java.. so if i run a java code it should turn HIGH digital pin 2 .. Would really appreciate any help.. Thanks..

Have a look at Processing.

thanks a lot for the reply.. i did go through this link .. i have a few questions though.. suppose i download the arduino java library.. and upload the firmata standard sketch.. now i see that there is code like this to send 65 to a pin..

// Example by Tom Igoe

import processing.serial.*;

// The serial port: Serial myPort;

// List all the available serial ports: println(Serial.list());

// I know that the first port in the serial list on my mac // is always my Keyspan adaptor, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600);

// Send a capital A out the serial port myPort.write(65);

any way to modify this code to send a HIGH to pin 2 ?.Thanks..

any way to modify this code to send a HIGH to pin 2


could you help me with the necessary changes??thanks..

I think you may have misunderstood the purpose of the forum. It is to help people learn, not to have their homework done for them. When you've started and you're really stuck, come back and we'll help.

[edit]Hint: Spending 15 minutes looking at Processing doesn't qualify as "stuck".[/edit]

Thanks for your reply.. well im not a student and this isnt my homework :) .. i downloaded the processing and arduino library and added them to the classpath.. im trying to compile this java code using javac from the terminal

import processing.serial.; import cc.arduino.;

Arduino arduino; int ledPin = 13;

void setup() { //println(Arduino.list()); arduino = new Arduino(this, Arduino.list()[0], 57600); arduino.pinMode(ledPin, Arduino.OUTPUT); }

void draw() { arduino.digitalWrite(ledPin, Arduino.HIGH); delay(1000); arduino.digitalWrite(ledPin, Arduino.LOW); delay(1000); }

Although im getting a compile error class, interface, or enum expected Arduino arduino;

so i thought its probably because i've not put this inside a function.. but once i did that i get errors for the setup() and draw() part of the code.. would really appreciate some help..