Turn LED on and Off With Push Button Using Arduino & Visuino

by RonFrtek in Circuits > Arduino

97 Views, 2 Favorites, 0 Comments

Turn LED on and Off With Push Button Using Arduino & Visuino

2023-09-15_17-18-23D.png

In this tutorial we are going to learn how to turn the LED ON or OFF with a button. It is a simple tutorial for beginners on how to get started with Visuino. Since buttons are used a lot in many projects this will serve you as a great guide for the future prtojects.

What You Will Need

mini_push_button.1471344052-600x435.png
LED-RED.png
download (5).jpg
FB48IU6L01BWKAP.jpg
FJRR1KTKV2I5ZUA.jpg
F19QEZ5KK5FQW90.jpg
  • Arduino UNO (or any other Arduino or ESP)
  • 2X 1K ohm resistor
  • Button
  • LED
  • Jumper wires
  • Breadboard
  • Visuino program: Download Visuino

The Circuit

2022-04-07_20-36-06.jpg
  • Connect Arduino Digital pin [7] to button on the breadboard and to the Resistor1
  • Connect other side of the resistor1 to the breadboard pin [GND]
  • Connect Other pin of the button to the breadboard positive pin [5V]
  • Connect Arduino pin [5V] to breadboard positive pin [Red line]
  • Connect Arduino pin [GND] to breadboard negative pin [Black line]
  • Connect Arduino Digital pin [2] to the Resistor2
  • Connect other side of the resistor2 to the LED positive pin
  • Connect LED negative pin to breadboard pin [GND]

Start Visuino, and Select the Arduino UNO Board Type

F2LHQ1LL0FAEEUY.jpg
Visuino-Select-Board-UNO.jpg

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add & Connect Components

2022-04-07_20-41-33.jpg
2022-04-07_19-35-57.jpg
2022-04-07_19-44-52.jpg
  • Add "Debounce Button" component
  • Add "Toggle(T) Flip-Flop" component
  • Connect Arduino digital pin [7] to "Button1" pin [In]
  • Connect "Button1" pin [Out] to "TFlipFlop1" pin [Clock]
  • Connect "TFlipFlop1 pin [Out] to Arduino digital pin [2]

Generate, Compile, and Upload the Arduino Code

Visuino-Compile-UNO.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino module, press the button and the LED will turn ON or OFF.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this tutorial, you can download it and open it in Visuino: https://www.visuino.eu

Downloads