Back to Parent

int led1 = A0;
int led2 = D5;
int led3 = D1;
int ledGreen = D0;
int ledRed = D3;
int switchPin = A4;
int button1 = A2;

void setup() {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
     pinMode(ledGreen, OUTPUT);
    pinMode(ledRed, OUTPUT);
    pinMode(switchPin, INPUT);
    pinMode(button1, INPUT);

}

void loop() {
    // switch on for light display
    int switchRead = digitalRead(switchPin);
    int button1Read = digitalRead(button1);
    
    if (switchRead == HIGH) {
    digitalWrite(led1, HIGH);
    delay(200);
    digitalWrite(led1, LOW);
    delay(200);
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
    delay(200);
    digitalWrite(led1, HIGH);
    delay(200);
    digitalWrite(led1, LOW);
     delay(200);
    digitalWrite(led3, HIGH);
    delay(200);
    digitalWrite(led3, LOW);
     delay(200);
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
     delay(200);
    digitalWrite(led1, HIGH);
    delay(200);
    digitalWrite(led1, LOW);
    delay(200);
    digitalWrite(led1, HIGH);
    delay(200);
    digitalWrite(led1, LOW);
    delay(200);
    digitalWrite(led3, HIGH);
    delay(200);
    digitalWrite(led3, LOW);
    delay(3000);
    }
    else {
        if (button1Read == HIGH) {
            digitalWrite(ledGreen, HIGH);
        }
        else {
            digitalWrite(ledGreen, LOW);
        }
        
    }
    
    
}
Click to Expand

Content Rating

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

0