/* up = y 1023 , x 512
down = y 0 , x 512
right = y 512
left = y 512 , x, 1023
'B' stands for button
*/
// vetr = Y horz = X
#define led_b 7
#define led_up 10
#define led_down 11
#define led_left 12
#define led_right 13
#define x A1
#define y A0
#define b 2
int X_val;
int Y_val;
int B_val;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(x, INPUT);
pinMode(y, INPUT);
pinMode(led_up, OUTPUT);
pinMode(led_down, OUTPUT);
pinMode(led_left, OUTPUT);
pinMode(led_right, OUTPUT);
pinMode(led_b, OUTPUT);
digitalWrite(b, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
X_val = analogRead(x);
Y_val = analogRead(y);
B_val = digitalRead(b);
if(X_val == 512 , Y_val == 1023 ){
digitalWrite(led_up, HIGH);
}else{
digitalWrite(led_up, LOW);
}
if(X_val == 512 , Y_val == 0){
digitalWrite(led_down, HIGH);
}
else{
digitalWrite(led_down, LOW);
}
if(Y_val == 512 , X_val == 0){
digitalWrite(led_right, HIGH);
}
else{
digitalWrite(led_right, LOW);
}
if( Y_val == 512 , X_val == 1023){
digitalWrite(led_left,1);
}
else{
digitalWrite(led_left, LOW);
}
if(B_val == 0){
digitalWrite(led_b, HIGH);
}
else{
digitalWrite(led_b, LOW);
}
Serial.print("x data :");
Serial.print(X_val);
Serial.print("\t");
Serial.print("y data :");
Serial.print(Y_val);
Serial.print("\t");
Serial.print("b_data :");
Serial.println(B_val);
delay(100);
}