Introduction: Happy Hack: LEDs and a Pushbutton

Picture of Happy Hack: LEDs and a Pushbutton

What you need:

-2 breadboards

-1 Arduino Uno

-11 resistors in total: 10 red-red-black, 1 orange-orange-brown

-10 LEDs

-Wires: 12 short, 6 middle short, 4 middle large, 4 large

- 1 pushbutton

- 1 USB-cable

Step 1: Step 1: Add the LEDs

Picture of Step 1: Add the LEDs

Step 2: Step 2: Do the Same Thing With the Other Breadboard

Picture of Step 2: Do the Same Thing With the Other Breadboard

Step 3: Add the Pushbutton

Picture of Add the Pushbutton

Step 4: Step 4: Add a Wire to the Arduino Uno to 5Volt

Picture of Step 4: Add a Wire to the Arduino Uno to 5Volt

Step 5: Step 5: Add a Wire to the Arduino to GND

Picture of Step 5: Add a Wire to the Arduino to GND

Step 6:

Picture of

Step 7: Add a Resistant With the Colors Orange-orange-brown

Picture of Add a Resistant With the Colors Orange-orange-brown

Step 8:

Picture of

Step 9: Add a Wire to Connect the Breadboards

Picture of Add a Wire to Connect the Breadboards

Step 10: Connect You Arduino Uno to Your Computer With the USB-cable

Picture of Connect You Arduino Uno to Your Computer With the USB-cable

Here is the code you need to use on your computer to make the Arduino work:

int buttonState = 0;

void setup() { pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); pinMode(10, OUTPUT); pinMode(9, OUTPUT); pinMode(7, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); pinMode(4, OUTPUT); pinMode(3, OUTPUT); pinMode(2, INPUT); }

void loop() { buttonState = digitalRead(2); if (buttonState == LOW) { digitalWrite(13, HIGH); delay(300); digitalWrite(12,HIGH); delay(300); digitalWrite(11, HIGH); delay(300); digitalWrite(10, HIGH); delay(300); digitalWrite(9, HIGH); delay(300); digitalWrite(7, HIGH); delay(300); digitalWrite(6, HIGH); delay(300); digitalWrite(5, HIGH); delay(300); digitalWrite(4, HIGH); delay(300); digitalWrite(3, HIGH); delay(300); } else { digitalWrite(13, LOW); delay(250); digitalWrite(12,LOW); delay(250); digitalWrite(11, LOW); delay(250); digitalWrite(10, LOW); delay(250); digitalWrite(9, LOW); delay(250); digitalWrite(7, LOW); delay(250); digitalWrite(6, LOW); delay(250); digitalWrite(5, LOW); delay(250); digitalWrite(4, LOW); delay(250); digitalWrite(3, LOW); delay(250); }}

Step 11: Push the Button and the LEDs Should Turn on One by One, and Then Off One by One!

Picture of Push the Button and the LEDs Should Turn on One by One, and Then Off One by One!

Comments

Swansong (author)2017-02-01

Thanks for sharing :)

About This Instructable

72views

0favorites

License:

More by Indiake:Happy Hack: LEDs and a Pushbutton
Add instructable to: