Copyright © Parallax Inc.
Page 4 of 4
Arduino Uno
void setup() {
Serial.begin(9600);
}
void loop() {
if(digitalRead(2) == LOW)
Serial.println("Left");
if(digitalRead(3)== LOW)
Serial.println("Down");
if(digitalRead(4) == LOW)
Serial.println("Right");
if(digitalRead(5) == LOW)
Serial.println("Up");
if(digitalRead(6) == LOW)
Serial.println("Center");
delay(200);
}
Note:
To view the results of the demonstration, after uploading is complete click the Serial
Monitor icon in the Arduino IDE. This displays the Serial Monitor window. Momentarily
depress the Reset button on the Arduino board to restart the sketch.
For More Information
•
See the