is arduino code different in processing?
in
Integration and Hardware
•
1 year ago
Hello,
I am having a strange problem and banging my head into the wall.
I have some code on arduino (a Mega) that works fine but when I transfer that code to processing/Firmata using the arduino library it doesn't seem to work. I just want to push a button and have things happen on the computer.
So with the arduino code I have:
if (digitalRead(53)==HIGH) {
Serial.println("53!");
digitalWrite(13, HIGH);
delay(50);
}
And with processing I have:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
size(470, 280);
arduino = new Arduino(this, Arduino.list()[1], 57600);
arduino.pinMode(53, Arduino.INPUT);
}
void draw() {
background(0);
fill(255);
if (arduino.digitalRead(53) == Arduino.HIGH) {
ellipse(280, 280, 280, 280);
}
}
But yet I cannot get that ellipse to draw. Oddly, if I change the HIGH to a LOW in the code and run the program, the ellipse is there. So it seems to notice the button maybe....there must be some small thing I'm missing here! I tried changing the caps on Arduino and arduino but that didn't work, I have simplified the code so it's exactly the same as the Arduino code! When I run the arduino library test programs in Processing everything works fine so I know I have everything hooked up correctly....
What am I doing wrong???
**edit: the OUTPUT test program works in the arduino library for processing but the INPUT program does not. Does the library not work with an arduino Mega?
***edit2: downloaded the mega library from here:
http://www.arduino.cc/playground/interfacing/processing
but in the library folder...nothing was there!!! So I got this one:
http://nilseuropa.com/?p=139 but it still isn't working!
1