Button Input for LED
As we know, the flashlight needs a switch to control the LED’s on and off. This circuit adds a button to the basic LED circuit and cooperates with the code to achieve this function.
What way it may look like if you build this circuit with an Arduino kit:

Try to build this circuit in Tinkercad Circuits:
Step 1: Find the Sample Code
The code for this project can be found: File > Examples > 02. Digital > Button

Look closely at comments to see how the code works.

Step 2: Connect one side of the button to the “+”
Use a jump wire between the “+” and one of the button’s legs

Step 3: Connect the second leg of the button to Pin 2

Step 4: Add 1K Ohm Resistor- NOT 220 Ohm
Connect the resistor to the second leg of the button. Other side connect to the “-” bus

Step 5: Build an independent loop with the LED
Connect the pin 13 to any unoccupied row, and the circuit could look like this :

Step 6: Test the Code
After we paste the code and start the simulation, when you press the button, both the onboard LED and the LED on the breadboard will light up!

Introduction |
Lesson One: System Design |
Lesson Two: Basic Circuitry Knowledge |
Lesson Three: Electronics Tools |
Lesson Four: Lighting an LED |
Lesson Five: Tilt Switch |
Lesson Six: Photoresistor and LED |
Lesson Seven: Button with Piezo Speaker |
Lesson Eight: Dimming an LED |
Lesson Nine: Button Input for LED |
Lesson Ten: Ultrasonic Sensor Alarm |
Further Resources |