We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So i build something so that when you push a button, an LED is going to light up
Now the issue that I'm having is that when i click the button, it doesn't do anything
this is my code in processing
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int BUTTON1 = 11;
int BUTTON2 = 10;
int BUTTON3 = 9;
int BUTTON4 = 8;
void setup()
{
size(600, 600);
arduino = new Arduino(this, Arduino.list()[0], 57600);
}
void draw()
{
int x = 150;
int y = 150;
ellipse(x,y,50,50);
if(arduino.digitalRead(BUTTON1) == Arduino.HIGH) {
x = x + 50;
}
}
I hope that someon can help me
Answers
Please edit your post (gear icon in the top right corner of your post), select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
You can check previous posts: https://forum.processing.org/two/search?Search=arduino
When you were turning the LED, were you doing it from Processing?
Kf
I edited the post, the LED does turn on because i've programmed that in Arduino, but the ellipse in processing doesn't move
Can you post your ino code?
Kf
Is this your first sketch interacting with an arduino unit or have you done it before?
Are you using firmata? If so, this post could help: https://forum.processing.org/two/discussion/20955/arduino-not-being-reset-when-running-a-processing-sketch/p1
AND https://adestefawp.wordpress.com/learning/using-arduino-firmata-and-processing-together/
Otherwise, you could use the following examples, reading the bytes directly from the serial port. Remark: If you loaded the firmata code into your arduino, you should stick to the above comment.
https://forum.processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_5
https://forum.processing.org/two/discussion/14534/myport-available-always-0#Item_1
Kf
I do use firmata, and still it doesn't move when i click BUTTON1
So my understanding is that if you use firmata, then you should be interacting with your arduino exclusively from Processing. I don't understand how you can be changing the LED from your arduino code if you have loaded the firmata in your arduino device.
I suggest following the firmata example provided in the previous post: https://adestefawp.wordpress.com/learning/using-arduino-firmata-and-processing-together/
Kf