int red = 5;
int yellow = 6;
int green = 7;
int blue = 8;
void setup() {
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
void loop() {
if (analogRead(A0) > 1000) // Y
{
Serial.println("TOP");
digitalWrite(red, HIGH);
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
if (analogRead(A1) ==0) // X
{
Serial.println("RIGHT");
digitalWrite(red, LOW);
digitalWrite(yellow, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
if (analogRead(A0) ==0) // -Y
{
Serial.println("BOTTOM");
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}
if (analogRead(A1) > 1000) // -X
{
Serial.println("LEFT");
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
}
if (analogRead(A2) ==0) // Z
{
Serial.println("BUTTOM PRESSED");
digitalWrite(red, HIGH);
digitalWrite(yellow, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
}
else{
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
}