First of all thanks for interest,
i am working on one project in which i want to control relay by key board,
like when i press key "A" than pin 1 should on, i have completed this project by StandardFirmata which is available in example,
first(befor this problem) after uploading StandardFirmata to my arduino board all pins giving low output at the start up,
but now my all pins giving high(5v) at startup , even without any control through firmata test application.
yesterday it was working perfectly.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
color off = color(4, 79, 111);
color on = color(84, 145, 158);
int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW };
void setup() {
size(470, 200);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.OUTPUT);
}
void draw() {
background(off);
stroke(on);
for (int i = 0; i <= 13; i++) {
if (values[i] == Arduino.HIGH)
fill(on);
else
fill(off);
rect(420 - i * 30, 30, 20, 20);
}
}
void keyPressed(){
int pin = -1;
if( key == 'a' || key == 'A' ){
pin = 0;
}
if( key == 'b' || key == 'B' ){
pin = 1;
}
if( key == 'c' || key == 'C' ){
pin = 2;
}
if( key == 'd' || key == 'D' ){
pin = 3;
}
if( key == 'e' || key == 'E' ){
pin = 4;
}
if( key == 'f' || key == 'F' ){
pin = 5;
}
if( key == 'g' || key == 'G' ){
pin = 6;
}
if( key == 'h' || key == 'H' ){
pin = 7;
}
if( key == 'i' || key == 'I' ){
pin = 8;
}
if( key == 'j' || key == 'J' ){
pin = 9;
}
if( key == 'k' || key == 'K' ){
pin = 10;
}
if( pin != -1 && pin < values.length ){
if (values[pin] == Arduino.LOW) {
arduino.digitalWrite(pin, Arduino.HIGH);
values[pin] = Arduino.HIGH;
} else {
arduino.digitalWrite(pin, Arduino.LOW);
values[pin] = Arduino.LOW;
}
}
}