brambi001
Published © GPL3+

Simple LED project

Little project using 2 buttons to turn ON and OFF a line of 5 LEDS!

BeginnerProtip36
Simple LED project

Things used in this project

Code

Code

C/C++
int ledb=11;
int ledg=9;
int ledy=7;
int ledr=5;
int ledw=3;
int button1=13;
int button2=0;

void setup() {
  pinMode(ledb, OUTPUT);
  pinMode(ledg, OUTPUT);
  pinMode(ledy, OUTPUT);
  pinMode(ledr, OUTPUT);
  pinMode(ledw, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
}
void loop() {
  if (digitalRead(button1)==LOW) {
    digitalWrite(ledb, HIGH);
    digitalWrite(ledg, HIGH);
    digitalWrite(ledy, HIGH);
    digitalWrite(ledr, HIGH);
    digitalWrite(ledw, HIGH);
  }
  if (digitalRead(button2)== LOW) {
        digitalWrite(ledb, LOW);
    digitalWrite(ledg, LOW);
    digitalWrite(ledy, LOW);
    digitalWrite(ledr, LOW);
    digitalWrite(ledw, LOW);
  }
}

Credits

brambi001
6 projects • 3 followers

Comments