top of page
-
const int RED_PIN = 5;
-
const int YELLOW_PIN = 3;
-
const int GREEN_PIN = 4;
-
const int pot_pin = A0;
-
int pot_val;
-
-
void setup() {
-
// put your setup code here, to run once:
-
Serial.begin(9600);
-
pinMode(RED_PIN, OUTPUT);
-
pinMode(YELLOW_PIN, OUTPUT);
-
pinMode(GREEN_PIN, OUTPUT);
-
}
-
-
void loop() {
-
// put your main code here, to run repeatedly:
-
pot_val = analogRead(pot_pin);
-
Serial.println(pot_val);
-
if(pot_val <= 341){
-
digitalWrite(RED_PIN, HIGH);
-
digitalWrite(YELLOW_PIN, LOW);
-
digitalWrite(GREEN_PIN, LOW);
-
}
-
else if(pot_val <= 682){
-
digitalWrite(RED_PIN, LOW);
-
digitalWrite(YELLOW_PIN, HIGH);
-
digitalWrite(GREEN_PIN, LOW);
-
}
-
else{
-
digitalWrite(RED_PIN, LOW);
-
digitalWrite(YELLOW_PIN, LOW);
-
digitalWrite(GREEN_PIN, HIGH);
-
}
-
delay(500);
-
}
bottom of page