Push Button Controlled LED.


Push Button Controlled LED

In This Project, You’Ll Add A Push Button Switch To An Led Circuit To Control When The Led Is Lighting.

Parts Required :




Arduino UNO


Arduino UNO

Breadboard


Breadboard

Jumper Wires


Jumper Wires

LED


LED

Push Button


Push Button

Resistor 1 10k-Ohm


Resistor 1 10k-Ohm

Resistor 2 220-Ohm


Resistor 2 220-Ohm

This Project Will Take You Through The Basics Of Switches, Almost All Electrical Items Use Switches To Turn An Element On Or Off. There Are Many Types Of Switches, And The One You’Ll Use Now Is A Push Button.




How It Works:




When Pressed, A Push Button Completes A Circuit, Turning It On. As Soon As The Button Is Released, The Connection Will Spring Back And Break That Circuit, Turning It Off. The Push Button Switch Is Also Known As A Momentary Or Normally Open Switch, And Is Used In, For Example, Computer Keyboards. This Is In Contrast To A Toggle Switch, Which Stays Either On Or Off Until You Toggle It To The Other Position, Like A Light Switch.

This Type Of Push Button Has Four Pins, But You Generally Use Only Two At A Time For Connection. You’Ll Use The Top Connections In This Project, Although The Two Unused Pins At The Bottom Would Do The Same Job.

The Build:


Breadboard:


Breadboard:

Schematic:


download

Confirm That Your Setup Matches The Circuit Diagram, And Then Upload The Code.

The Code:




In This Code, You Assign A Pin For The Push Button And Set It As Input, And A Pin For The Led And Set It As Output. The Code Tells The Arduino To Turn The Led On As Long As The Button Is Being Pressed (Completing The Circuit), And To Keep The Led Off When The Button Is Not Being Pressed. When The Button Is Released, The Circuit Breaks And The Led Will Turn Off Again.