Back to Parent

//exercise 3: add a second LED to the circuit and alternate blinks

int led1 = D2;
int led2 = D3;

void setup() {
    
    pinMode (led1, OUTPUT);
    pinMode (led2, OUTPUT);
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
    
}

void loop(){
    
    digitalWrite(led1, HIGH); //turn on LED 1
    delay(500);
    
    digitalWrite(led1, LOW); //turn off LED 1
    delay(500);
    
    
    digitalWrite(led2, HIGH); //turn on LED 2
    delay(500);
    
    digitalWrite (led2, LOW); //turn off LED 2
    delay (500);
   
   //repeat
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0