Stap 5: En hier is de code
#define newLED 2 / / groene LED 'nieuw'
#define okLED 4 / / gele LED 'ok'
#define oldLED 6 / / rood LED 'oude'
zweven analogValue = 0;
zweven spanning = 0;
int ledDelay = 2000;
VOID Setup {}
pinMode (newLED, OUTPUT);
pinMode (okLED, OUTPUT);
pinMode (oldLED, OUTPUT);
}
void loop {function;}
void function {analogValue = analogRead(0);
spanning = 0.0048 * analogValue;
Als (spanning > = 1.6) {}
digitalWrite (newLED, hoge);
delay(ledDelay);
digitalWrite (newLED, laag);
} else if (spanning < 1.6 & & spanning > 1.4) {}
digitalWrite (okLED, hoge);
delay(ledDelay);
digitalWrite (okLED, laag);
} else if (spanning < = 1.4) {}
digitalWrite (oldLED, hoge);
delay(ledDelay);
digitalWrite (oldLED, laag);
} }