Hi all, I'm trying out a simple program to find out how Processing works in controlling an Arduino board using Firmata.
import processing.serial.*;
import cc.arduino.*;
//input pin for button 1
int button1Pin = 2;
//output pin for LED 1
int button1LED = 13;
int buttonState = 0;
Arduino arduino;
void setup()
{
arduino = new Arduino(this,Arduino.list()[2],9600);
arduino.pinMode(button1Pin,Arduino.INPUT);
arduino.pinMode(button1LED,Arduino.OUTPUT);
println(Arduino.list());
}
void draw()
{
buttonState = arduino.digitalRead(button1Pin);
if(buttonState == Arduino.HIGH)
{
arduino.digitalWrite(button1LED,Arduino.HIGH);
println("button1 is HIGH");
}
else
{
arduino.digitalWrite(button1LED,Arduino.LOW);
println("button1 is LOW");
}
}
I am trying a simple experiment, trying to turn on an LED with a button.
This is the Processing sketch. It can run without errors, but it doesn't seem to take any input from the button.
On the Arduino side, I uploaded the StandardFirmata sketch.
Is this correct or do I need to do other coding on the Arduino sketch as well?
[Moderator's note: this is question for the Integration and Hardware section (nearly all questions are programming-related, choose the most specific section please). Moved it.]