int butten = 2;
void setup() {
Serial.begin(9600);
}
void loop(){
int buttenState = digitalRead(butten);
Serial.println(buttenState);
delay(2);
}// dab more
//------------------Processing code below, paste below------
/* (begin) import processing.serial.*;
Serial myPort;
int X=10;
int Y=200;
PFont font;
float inByte;
void setup(){
size(1000,400);
font=createFont("Arial-BoldItalicMT-48",50);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
}
void draw(){
background(#000000);
fill(226,160,18);
rect(0,300,1000,100);
rect(0,0,1000,100);
fill(255,246,0);
rect(950,100,50,200);
fill( #00FF00 );
rect(X,Y,10,10);
X=X+1;
if(inByte>=1){
Y=Y-1;
} else{
Y=Y+1;
}
if(X>950){
textFont(font);
text("YOU DID IT!!!",500,200);
X=975;
Y=200;
}
if(Y>300||Y<100){
text("YOU LOSE!!!",500,200);
X=10;
Y=200;
}
}
void serialEvent (SerialcPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
inByte = float(inString);
println(inByte);
}
}//dab more
(end)*/
Comments
Please log in or sign up to comment.