Table of Contents
Example Description
A relay is an electromagnetic switch which is used to control high voltage appliances using microcontrollers.
Introduction

A relay is an electromagnetic switch that works on the principle of electromagnetic induction. A Realy is used to control the high voltage appliances using the microcontrollers.

5V Single-Channel Relay Module - Pin Diagram, Specifications, Applications, Working

a relay has a primary side which is need to be connected to the controller and the secondary side is need to be connected with the load, for example, motor, light bulb, fan, etc. primary side has 3 pins named as VCC, GND, and IN.  secondary also has connections named as Common(COM), Normally Open(NO), and Normally Closed (NC).

Circuit

connection

relay              Arduino

VCC                 5V

GND               GND

IN                  D7

COM             battery-

NO                1 leg of the bulb

Code

  1. From  event palette,  add when  flag clicked  into the scripting area
  2. From controls add a forever block
  3. Now go to actuator palette, and drag set relay at pin () to () into forever loop.
  4. Add a wait block from control palette.
  5. Repeat above 2 steps and change relay state from OFF to ON

 

Script

Output