Pressing button draws a shape
hello everyone!
i'm new processing , arduino , trying sounds simple, guess not. (or maybe , i'm not getting it...)
my goal have breadboard 12 buttons attached arduino, , when press button shape drawn in processing. each button draw different shape.
this code tried adapt button , led example doesn't work. please me!
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 pressed!");
buttonpressed = true;
fill(255);
nostroke();
rotate(random(360));
rect(random(1200), random(700), random(300), 10);
}
}
i'm new processing , arduino , trying sounds simple, guess not. (or maybe , i'm not getting it...)
my goal have breadboard 12 buttons attached arduino, , when press button shape drawn in processing. each button draw different shape.
this code tried adapt button , led example doesn't work. please me!
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 pressed!");
buttonpressed = true;
fill(255);
nostroke();
rotate(random(360));
rect(random(1200), random(700), random(300), 10);
}
}
how switch wired @ arduino. here accepted switch wiring (note low digital input when button pushed). running firmata on arduino.
Arduino Forum > Using Arduino > Programming Questions > Pressing button draws a shape
arduino
Comments
Post a Comment