int ledPinR = 23; // the number of the LED pin
int ledStateR = LOW; // ledState used to set the LED - HIGH or LOW
long previousMillisR = 0; // will store last time LED was updated const long interval = // 1000;
int intervalR = 1000; // interval at which to blink (milliseconds)
int ledPinG = 18; // the number of the LED pin
int ledStateG = LOW; // ledState used to set the LED - HIGH or LOW
long previousMillisG = 0; // will store last time LED was updated const long interval = // 1000;
int intervalG = 500; // interval at which to blink (milliseconds)
int ledPinY = 19; // the number of the LED pin
int ledStateY = LOW; // ledState used to set the LED - HIGH or LOW
long previousMillisY = 0; // will store last time LED was updated const long interval = // 1000;
int intervalY = 2000; // interval at which to blink (milliseconds)
void setup()
{
pinMode(ledPinR, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(ledPinY, OUTPUT);
}
void loop()
{
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the LED.
long currentMillis = millis();
if ( currentMillis - previousMillisR >= intervalR)
{
previousMillisR = currentMillis; // save the last time you blinked the LED
if (ledStateR == LOW)
{
ledStateR = HIGH;
}
else
{
ledStateR = LOW;
}
digitalWrite(ledPinR, ledStateR);
}
if ( currentMillis - previousMillisG >= intervalG)
{
previousMillisG = currentMillis; // save the last time you blinked the LED
if (ledStateG == LOW)
{
ledStateG = HIGH;
}
else
{
ledStateG = LOW;
}
digitalWrite(ledPinG, ledStateG);
}
if ( currentMillis - previousMillisY >= intervalY)
{
previousMillisY = currentMillis; // save the last time you blinked the LED
if (ledStateY == LOW)
{
ledStateY = HIGH;
}
else
{
ledStateY = LOW;
}
digitalWrite(ledPinY, ledStateY);
}
}