arduino led color control via a computer program

hey i was wondering how to control 4 or 5 leds, buy turning them off and on with a computer program, preferably using eclipse to make the computer program how is this accomplished.

thanks john

Don’t know anything about eclipse, but this is exactly what the Standard_Firmata is for. You would need to install processing http://processing.org/ (which the arduino IDE is based on btw), and the firmata library in the processing sketchbook http://www.arduino.cc/playground/Interfacing/Processing. And (of course) an arduino running Standard_Firmata on its end (should be included in Examples - Firmata menu).

Btw, seems like Firmata can be used with a lot of other languages too (I’ve just barely touched it with processing): Main Page - Firmata

I would use Visual Basic app builder for this. It would be simple to create this program by editing example programs on the website.

well i took on processing, and its amazing because i can put it into eclipse. with eclipse i can use C++ to program the innards of a Java based look and well it has so far been grate. since i use Ubuntu it makes it really easie to use and implament a program that can pretty much any thing i can come up with.

heres what i have so far.

this is processing code:

import processing.serial.*;
Serial myPort;

int val;
int rectX1 = 0,rectY1 = 0;
int rectwidth1 = 320;
int recthight1 = 240;
int rectX2 = 320,rectY2 = 0;
int rectwidth2 = 319;
int recthight2 = 240;
int rectX3 = 0,rectY3 = 240;
int rectwidth3 = 320;
int recthight3 = 240;
int rectX4 = 320,rectY4 = 240;
int rectwidth4 = 319;
int recthight4 = 240;

PFont fontA;

void setup()
{
  size(640,480);
  smooth();
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
  fontA = loadFont("CourierNew36.vlw");
  textAlign(CENTER);
  textFont(fontA, 20);
  background(255);
}

void draw()
{
  stroke(0);
  fill(5,15,255);
  rect(rectX1, rectY1, rectwidth1, recthight1);
  fill(0,0,0);
  text("BLUE ON",rectwidth1 / 2,recthight1 / 2);
  if ( overRect1(rectX1, rectY1, rectwidth1, recthight1) ) 
  {
    if (mousePressed)
    {
      myPort.write('0');
    }
  }
  else
  {
    myPort.write('5');
  }
  stroke(0);
  fill(255,0,0);
  rect(rectX2, rectY2, rectwidth2, recthight2);
  fill(0,0,0);
  text("RED ON",rectwidth2 + rectwidth2 / 2,recthight2 / 2);
  if ( overRect2(rectX2, rectY2, rectwidth2, recthight2) ) 
  {
    if (mousePressed)
    {
      myPort.write('1');
    }
  }
  else
  {
    myPort.write('6');
  }
  stroke(0);
  fill(0,255,0);
  rect(rectX3, rectY3, rectwidth3, recthight3);
  fill(0,0,0);
  text("GREEN ON",rectwidth3 / 2,recthight3 + (rectwidth3 / 2)-20);
  if ( overRect3(rectX3, rectY3, rectwidth3, recthight3) ) 
  {
    if (mousePressed)
    {
      myPort.write('2');
    }
  }
  else
  {
    myPort.write('7');
  }
  stroke(0);
  fill(255,255,255);
  rect(rectX4, rectY4, rectwidth4, recthight4);
  fill(0,0,0);
  text("WHITE ON",rectwidth4 + (rectwidth4 / 2),recthight4 + (rectwidth4 / 2) - 20);
  if ( overRect4(rectX4, rectY4, rectwidth4, recthight4) ) 
  {
    if (mousePressed)
    {
      myPort.write('3');
    }
  }
  else
  {
    myPort.write('8');
  }
}
boolean overRect1(int x, int y, int width, int height) 
{
  if (mouseX >= x && mouseX <= x+width && 
      mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}
boolean overRect2(int x, int y, int width, int height) 
{
  if (mouseX >= x && mouseX <= x+width && 
      mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}
boolean overRect3(int x, int y, int width, int height) 
{
  if (mouseX >= x && mouseX <= x+width && 
      mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}
boolean overRect4(int x, int y, int width, int height) 
{
  if (mouseX >= x && mouseX <= x+width && 
      mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}

here’s the arduino code:

int val; // Data received from the serial port
int ledPin1 = 12; // Set the pin to digital I/O 4
int ledPin2 = 11;
int ledPin3 = 9;
int ledPin4 = 10;
void setup()
{
  pinMode(ledPin1, OUTPUT); // Set pin as OUTPUT
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  Serial.begin(9600); // Start serial communication at 9600 bps
}

void loop()
{
  if (Serial.available())
  { // If data is available to read,
    val = Serial.read(); // read it and store it in val
  }
  if (val == '0')
  { // If H was received
    digitalWrite(ledPin1, HIGH); // turn the LED on
  } 
  if (val == '5')
  {
    digitalWrite(ledPin1, LOW); // Otherwise turn it OFF
  }
  if (val == '1')
  { // If H was received
    digitalWrite(ledPin2, HIGH); // turn the LED on
  }
  if (val == '6')
  {
    digitalWrite(ledPin2, LOW); // Otherwise turn it OFF
  }
  if (val == '2')
  { // If H was received
    digitalWrite(ledPin3, HIGH); // turn the LED on
  }
  if (val == '7')
  {
    digitalWrite(ledPin3, LOW); // Otherwise turn it OFF
  }
  if (val == '3')
  { // If H was received
    digitalWrite(ledPin4, HIGH); // turn the LED on
  }
  if (val == '8')
  {
    digitalWrite(ledPin4, LOW); // Otherwise turn it OFF
  }

  delay(1); // Wait 10 milliseconds for next reading
}

here’s what the program looks like and turns on all the LEDs on at a time.

http://sphotos.ak.fbcdn.net/hphotos-ak-snc3/hs337.snc3/29454_134370399907296_100000030113657_351009_5977207_n.jpg