int ledPin = 23; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED
int interval = 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
long previousMillisG = 0; // will store last time LED
int intervalG = 500;
int ledPinY = 19; // the number of the LED pin
int ledStateY = LOW; // ledState used to set the LED
long previousMillisY = 0; // will store last time LED
int intervalY = 2000;
void setup()
{
pinMode(ledPin, 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 - previousMillis >= interval) //currentMillis remains the same as
//you are checking from the same clock
{
previousMillis = currentMillis; // save the last time you blinked the LED
if (ledState == LOW)
{
ledState = HIGH;
}
else
{
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}
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);
}
}