Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitchwhocodes/3073e62e86ea1b4a58fd to your computer and use it in GitHub Desktop.
Save bitchwhocodes/3073e62e86ea1b4a58fd to your computer and use it in GitHub Desktop.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int led = 12;
int button = 2;
int value = 0;
void setup() {
size(400, 200);
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(led, Arduino.OUTPUT);
arduino.pinMode(button,Arduino.INPUT);
}
void draw() {
background(0, 0, 0 );
fill(255,255,255);
textAlign(CENTER);
textSize(16);
value = arduino.digitalRead(button);
if(value > 0 ){
text("BANG! THERE GOES THE BUTTON ", width/2, 25 );
blinkButton();
}else{
arduino.digitalWrite(led,Arduino.LOW);
text("Waiting for you to press the button ", width/2, 25 );
}
}
void blinkButton( ){
//let's blink the led
arduino.digitalWrite(led, Arduino.HIGH);
delay(100);
arduino.digitalWrite(led, Arduino.LOW);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment