void setup() {
Robot.begin();
Robot.beginTFT();
Robot.beginSD();
}
void loop() {
int val=map(Robot.knobRead(), 0, 1023, -255, 255);
Robot.motorsWrite(val,val);
delay(10);
int key = Robot.keyboardRead();
switch(key) {
case BUTTON_LEFT:
Robot.turn(-90);
Robot.motorsStop();
setHappyFace(true);
delay(2000);
setHappyFace(false);
break;
case BUTTON_RIGHT:
Robot.turn(90);
Robot.motorsStop();
setHappyFace(true);
delay(2000);
setHappyFace(false);
break;
case BUTTON_DOWN:
Robot.turn(180);
Robot.motorsStop();
setHappyFace(true);
delay(2000);
setHappyFace(false);
break;
case BUTTON_MIDDLE:
setSadFace(false);
delay(2000);
setSadFace(false);
break;
case BUTTON_NONE:
setHappyFace(false);
break;
}
}
void setHappyFace(boolean onOff) {
if(onOff) {
Robot.background(225, 225, 255);
Robot.setCursor(15, 60);
Robot.stroke(0, 0, 0);
Robot.setTextSize(2);
Robot.text("makin/n my way/n downtown", 5, 5,true);
}else
Robot.background(255, 225, 225);
Robot.setCursor(15, 60);
Robot.stroke(0, 0, 0);
Robot.setTextSize(2);
Robot.text("dont touch/n me there/n >:(", 5, 5,false);
delay(1000);
return;
}
Aucun commentaire:
Enregistrer un commentaire