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.
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
- From event palette, add when flag clicked into the scripting area
- From controls add a forever block
- Now go to actuator palette, and drag set relay at pin () to () into forever loop.
- Add a wait block from control palette.
- Repeat above 2 steps and change relay state from OFF to ON