Paso 8: Arduino
const int ledPin1 = 2;
const int ledPin2 = 3;
const int ledPin3 = 13;
const int buttonPin = 4;
const int intervalo = 100;
const int interval2 = 100;
Boolean led1State = bajo;
Boolean led2State = alto;
Boolean led3State = bajo;
previousMillis largo = 0;
largo currentMillis;
previousMillis2 largo = 0;
void setup()
{
pinMode (ledPin1, salida);
pinMode (ledPin2, salida);
pinMode (ledPin3, salida);
pinMode (buttonPin, INPUT_PULLUP);
}
void loop()
{
currentMillis = millis();
Si ((currentMillis-previousMillis) > intervalo)
{
previousMillis = currentMillis;
led1State =! led1State;
led2State =! led2State;
}
if(digitalRead(buttonPin)==LOW)
{
Si ((currentMillis-previousMillis2) > interval2)
{
previousMillis2 = currentMillis;
led3State =! led3State;
}
}
if(digitalRead(buttonPin)==High)
{
led3State = bajo;
}
digitalWrite (ledPin1, led1State);
digitalWrite (ledPin2, led2State);
digitalWrite (ledPin3, led3State);
}