What is relay?
What is Ultrasonic Sensor
How does work relay?
Aim
Performing an experiment of RELAY with using ultrasonic and LED on Tinkercad
Required component
U1 1 Arduino Uno R3
K1 1 Relay SPDT
DIST1 1 Ultrasonic Distance Sensor
D1 1 Red LED
R1 1 1 kΩ Resistor
About Component
What is relay?
A relay is an electrically operated switch that opens or closes a circuit by activating an electromagnet to either allow or interrupt the flow of current. It acts as an intermediary between two circuits, allowing one circuit to control another circuit without making direct contact.
Relays are commonly used to control high-power electrical equipment such as motors, lights, and heaters, as well as to perform functions such as multiplexing and amplification. They can also be used in a variety of other applications, including communications, automation, and safety systems.
How does work relay?
A relay is an electrically operated switch that is used to turn on and off a circuit by a low-power signal, or "control signal," which is passed through the relay's coil. The coil creates a magnetic field when energized, which attracts an armature to close the switch and complete the circuit. When the control signal is turned off, the magnetic field disappears, and a spring returns the armature to its original position, opening the switch and breaking the circuit.
Relays are commonly used in a wide range of applications, including automotive systems, electrical control systems, and telecommunications. They can be used to control high-power circuits with a low-power signal, to isolate two parts of a circuit, or to perform logic functions such as switching between multiple inputs.
In summary, a relay works by using a low-power control signal to activate a magnetic field, which in turn closes a switch to complete a circuit.
What is Ultrasonic Sensors?
Ultrasonic sensors are devices that use high-frequency sound waves to measure distance, speed, or presence of objects. They work by emitting an ultrasonic pulse and measuring the time it takes for the pulse to reflect off an object and return to the sensor. Based on this time, the distance to the object can be calculated.
Ultrasonic sensors are commonly used in a wide range of applications, including industrial automation, robotics, security systems, and consumer electronics. They can be used to detect the presence or absence of objects, to measure the distance to an object, or to determine the speed of an object. They are often used as a non-contact alternative to traditional mechanical switches, as they do not wear out or break like physical switches can.
Ultrasonic sensors are widely used in automation and control systems due to their accuracy, reliability, and versatility. They are also widely used in consumer electronics, such as parking assist systems in cars, as well as in robotics, where they can be used for obstacle avoidance and navigation.
What is Arduino?
Arduino is an open-source electronics platform based on simple, easy-to-use hardware and software. It is designed to make the process of using electronics in multidisciplinary projects more accessible to people without a background in electronics.
The platform consists of a range of boards that are based on microcontrollers, as well as a software development environment that runs on your computer. With the help of this software, you can write code to control the boards and interact with a variety of sensors and other components.
This makes it possible to create a wide range of projects, from simple LED blinkers to complex home automation systems.
Working process
After connect all the hardware, define the code as per the connected hardware at particular pin. The Arduino where all the component connected with wire.
Ultrasonic ECHO pin with pin digital pin no 8, TRIG pin with pin no 9, VCC with 5V power supply and one more last Ground with direct ground.
Relay: Lower 2nd terminal of Relay connected with Arduino digital pin no 3 for control to relay with code, and lower third point with Ground. Then upper 2nd and 3rd terminal merge with wire.
Does relay work on opposite connection?
Case I: If we connect any component like LED with upper 1st terminal of Relay, then that component will be turn on until Relay will be on, and component power supply will be terminated when power supply of Relay will be stop .
Case II: If we connect any component like LED with lower 1st terminal of Relay, then that component will be turn off until Relay will be on, and when supply will be terminated of Relay then component will be on.
But in our we have connected one LED on the Relay at upper 1st terminal that's why the LED will be turn on until the Relay will be on and LED will be off when Relay power will be terminated.
So, on the merging of Ultrasonic Sensor, Relay and LED. We have coded that when the any object distance will be far a way exact 100 cm of distance then then Relay will be tun on the the passing the digitalWrite LOW and LED will be off, but when the object distance will be increate greater than 100 cm the Relay will be turn on by the passing the digitalWrite HIGH and LED will be turn on.

