YouTube Video

Thing you need

Arduino UNO

BreadBoard & Breaboard Wire’s 

220 Ohm & 1K Ohm Resistor

Red LED (or any color)

Build it on Breadboard

Code it

First, I created an integer called save in order to store the button data

Now we need to set the led and Push button Pins
Okay now we are done with void setup and before it

in void loop
at first, we check if the button is pushed or not also we check the save integer to find out if the LED is on or off (we only want to turn it on if it’s off) it shouldn’t be 1

Again, we also check if the button is pressed but time we want save integer to only be 1 (we only want to turn off the LED if it is on)

last but not least, what about the Whiles ? What are those ?
So if you push the button it will turn the LED on and off superfast that we cannot see and move our fingers, in order to stop that we use while to make the Arduino busy so it won’t go to other “if”

Thank you for reading/watching, please like and comment down below

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments