We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone!
I'm new to processing and arduino and I am trying to do something that sounds really simple, but I guess is not. (or maybe it is and I'm just not getting it...)
My goal is to have a breadboard with 12 buttons attached to an arduino, and when you press a button the a shape is drawn in processing. Each button will draw a different shape.
This is the code I tried to adapt from the button and led example but it doesn't work. Please help me! :D
import processing.serial.*; import cc.arduino.*;
Arduino arduino;
int btPin = 2;
Boolean buttonPressed=false;
void setup() {
size(1200, 700);
background(255);
//println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[4], 57600);
arduino.pinMode(btPin, Arduino.INPUT);
int buttonPressed=arduino.digitalRead(btPin);
print(buttonPressed);
}
void draw() {
if (buttonPressed) {
println("the button is pressed!");
buttonPressed = true;
fill(255);
noStroke();
rotate(random(360));
rect(random(1200), random(700), random(300), 10);
}
}