53 lines
928 B
C++
Executable File
53 lines
928 B
C++
Executable File
#define VRX 0
|
|
#define VRY 4
|
|
#define YELLOW 8
|
|
#define RED 7
|
|
#define JOYSTICK_VAL 600
|
|
#define JOY_BTN 2
|
|
|
|
int xVal = 0;
|
|
int yVal = 0;
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
Serial.begin(9600);
|
|
pinMode(RED, OUTPUT);
|
|
pinMode(YELLOW, OUTPUT);
|
|
Serial.write("Setup");
|
|
|
|
pinMode(JOY_BTN, INPUT_PULLUP);
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
xVal = analogRead(VRX);
|
|
//if(xVal != 0)
|
|
Serial.println("xVal:");
|
|
Serial.println(xVal);
|
|
Serial.println("\n");
|
|
|
|
yVal = analogRead(VRY);
|
|
Serial.println("yVal:");
|
|
Serial.println(yVal);
|
|
Serial.println("\n");
|
|
|
|
if(xVal >= JOYSTICK_VAL){
|
|
digitalWrite(RED, HIGH);
|
|
}else{
|
|
digitalWrite(RED, LOW);
|
|
}
|
|
|
|
if(yVal >= JOYSTICK_VAL){
|
|
digitalWrite(YELLOW, HIGH);
|
|
}else{
|
|
digitalWrite(YELLOW, LOW);
|
|
}
|
|
|
|
if(digitalRead(JOY_BTN) == LOW){
|
|
Serial.println("JOY_BTN button");
|
|
delay(3000);
|
|
}
|
|
|
|
delay(10);
|
|
}
|