Stap 8: De Arduino
Const int ledPin1 = 2;
Const int ledPin2 = 3;
Const int ledPin3 = 13;
Const int buttonPin = 4;
Const int interval = 100;
Const int interval2 = 100;
Boole led1State = laag;
Boole led2State = hoog;
Boole led3State = laag;
lange previousMillis = 0;
lange currentMillis;
lange previousMillis2 = 0;
VOID Setup
{
pinMode (ledPin1, OUTPUT);
pinMode (ledPin2, OUTPUT);
pinMode (ledPin3, OUTPUT);
pinMode (buttonPin, INPUT_PULLUP);
}
void loop
{
currentMillis = millis();
Als ((currentMillis-previousMillis) > interval)
{
previousMillis = currentMillis;
led1State =! led1State;
led2State =! led2State;
}
if(digitalRead(buttonPin)==low)
{
Als ((currentMillis-previousMillis2) > interval2)
{
previousMillis2 = currentMillis;
led3State =! led3State;
}
}
if(digitalRead(buttonPin)==High)
{
led3State = laag;
}
digitalWrite (ledPin1, led1State);
digitalWrite (ledPin2, led2State);
digitalWrite (ledPin3, led3State);
}