int vin = A2;
int ledr = 0;
int ledy = 1;
int ledg = 2;
void setup() {
pinMode(vin, INPUT);
pinMode(ledr, OUTPUT);
pinMode(ledy, OUTPUT);
pinMode(ledg, OUTPUT);
}
void loop() {
float readvin = (analogRead(vin)) * 0.0293255131964809;
if ((readvin > 0) && (readvin <= 11.5)) {
vrlow();
}
if ((readvin > 11.5) && (readvin <= 12.5)) {
vrmid();
}
if (readvin > 12.5) {
vrhi();
}
}
void vrlow() {
digitalWrite(ledr, HIGH);
delay(500);
digitalWrite(ledr, LOW);
delay(500);
}
void vrmid() {
digitalWrite(ledy, HIGH);
delay(500);
digitalWrite(ledy, LOW);
delay(3000);
}
void vrhi() {
digitalWrite(ledg, HIGH);
delay(500);
digitalWrite(ledg, LOW);
delay(6000);
}