Controlling 4 Channel Arduino Relay With Buttons

About the project

In this tutorial we will learn how to use 4 Channel Arduino Relay with Arduino and Visuino and controlling it with 4 buttons.

Project info

Difficulty: Easy

Platforms: ArduinoDFRobotVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Breadboard (generic) Breadboard (generic) x 1
DFRobot Gravity:Digital Push Button (Yellow) DFRobot Gravity:Digital Push Button (Yellow) x 4
Jumper wires (generic) Jumper wires (generic) x 1
Arduino UNO Arduino UNO x 1
Arduino 4 Relays Shield Arduino 4 Relays Shield x 1

Software apps and online services

Visuino - Graphical Development Environment for Arduino Visuino - Graphical Development Environment for Arduino
Arduino IDE Arduino IDE

Story

Step 1: What You Will Need

1 / 6

  • Arduino UNO (Or any other Board)
  • 4 Channel Arduino Relay
  • 4 button modules
  • Jumper wires
  • Visuino program: Download Visuino

Step 2: The Circuit With Buttons

  • Connect Arduino pin [GND] to each Button pin[GND]
  • Connect Arduino pin [VCC] to each Button pin[VCC]
  • Connect Arduino digital pin [6] to Button1 pin[Out]
  • Connect Arduino digital pin [7] to Button2 pin[Out]
  • Connect Arduino digital pin [8] to Button3 pin[Out]
  • Connect Arduino digital pin [9] to Button4 pin[Out]
  • Connect Arduino pin [GND] to Relay pin[GND]
  • Connect Arduino pin [VCC] to Relay pin[VCC]
  • Connect Arduino digital pin [2] to Relay pin[IN1]
  • Connect Arduino digital pin [3] to Relay pin[IN2]
  • Connect Arduino digital pin [4] to Relay pin[IN3]
  • Connect Arduino digital pin [5] to Relay pin[IN4]

Step 3: Start Visuino, and Select the Arduino UNO Board Type

1 / 2

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

Step 4: In Visuino Add & Set Components

1 / 4

  • Add 4X "Debounce Button" component
  • Add 4X "Toggle Flip Flop" component, this component is used to Switch the relay On or Off, by default the "Initial Value" is False, you can change it to True, this will set the Relay On at the start
  • Add 4X "Relay" component, this component is not necessary because it does not have any function, it is used only for easier visualization of the project

Step 5: In Visuino Connect Components

1 / 2

  • Connect Arduino digital pin [6] to "Button1" pin [In]
  • Connect Arduino digital pin [7] to "Button2" pin [In]
  • Connect Arduino digital pin [8] to "Button3 pin [In]
  • Connect Arduino digital pin [9] to "Button4" pin [In]
  • Connect "Button1" digital pin [Out] to "TFlipFlop1"pin [Clock]
  • Connect "Button2" digital pin [Out] to "TFlipFlop2"pin [Clock]
  • Connect "Button3" digital pin [Out] to "TFlipFlop3"pin [Clock]
  • Connect "Button4" digital pin [Out] to "TFlipFlop4"pin [Clock]
  • Connect "TFlipFlop1" digital pin [Out] to "Relay1"pin [In]
  • Connect "TFlipFlop2" digital pin [Out] to "Relay2"pin [In]
  • Connect "TFlipFlop3" digital pin [Out] to "Relay3"pin [In]
  • Connect "TFlipFlop4" digital pin [Out] to "Relay4"pin [In]
  • Connect "Relay1" pin [Out] to Arduino digital pin [2]
  • Connect "Relay2" pin [Out] to Arduino digital pin [3]
  • Connect "Relay3" pin [Out] to Arduino digital pin [4]
  • Connect "Relay4" pin [Out] to Arduino digital pin [5]

Step 6: Generate, Compile, and Upload the Arduino Code

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.

Step 7: Play

If you power the Arduino module and press the button the Relay will switch ON or OFF.

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

Schematics, diagrams and documents

Visuino File

Code

Visuino File

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...