#define LED 2
#define VERT_PIN A2
#define HORZ_PIN A1
#define SEL_PIN 2
int light = 0;
int up_down = 50;
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int horz = analogRead(HORZ_PIN);
int vert = analogRead(VERT_PIN);
if (vert < 300) {
light = light + up_down;
}
if (vert > 700) {
light = light - up_down;
}
if (horz > 700) {
light = light + up_down;
}
if (horz < 300) {
light = light - up_down;
}
// Serial.println(String(light));
if (light > 500 || light < 0){
light = 0;
}
analogWrite(LED, light);
delay(100);
}