Arduino programming exercises using Uno Microcontroller Write a program that turns on an LED for 3 seconds every time a button is pressed. Assume the button is wired active low.
Arduino
Write a program that turns on an LED for 3 seconds every time a button is pressed. Assume the button is wired active low.
Use tinkercad

Here our task is to implement an LED blinking program along with a push button.
When the button is pushed, the LED will turn on for 3 second.
Here, let us assume we connect LED to pin 13.
Connect push button to pin 2.
Since we aim an active low switch, initialize push button as 1(HIGH).
Once the push button state is logical 0 (LOW), we have to turn on LED and waits for 3 seconds. Else, turn off
So inorder to acquire this task we can implement an if - else conditional statement inside the loop function.
Our program code can be written as follows:
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images









