Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

NAME: M VENKATESH DATE:

ROLL NO: 21EG104D35 PAGE NO:

EXPERIMENT-V
SWITCH/SENSOR INTERFACING WITH MOTOR USING RELAY
AIM: To interface motor using relay with Arduino/Raspberry Pi and write a program to turn on motor when
sensor detectects heat.
REQUIREMENTS:

SOFTWARE REQUIRED:
1.Thonny IDE
2.Rasbian Operating System
HARDWARE REQUIRED:
1. Raspberry Pi kit(1)
2. Monitor(1)
3. HDMI cable(1)
4. Relay sensor(1)
5. Power supply
6. Motor(1)
7. Keyboard(1)
8. Mouse(1)
9. Connecting wire
10. Battery(1)
11. Power Adapter(1)
12. Incense Stick(1)
THEORY:
The main principle in controlling a DC Motor with Raspberry Pi lies with the Motor Driver. A Motor
Driver is a special circuit or IC that provides the necessary power to the motor for smooth and safe
operation.

Even a small 5V DC Motor draws a high initial current of around 300 – 400 mA. This current will then
fall down 150 – 200 mA as the motor gains speed to around.

This is a huge current for devices like Microcontrollers, Arduino, Raspberry Pi etc. Hence, we should
never connect a motor directly to Raspberry Pi .

Motor Driver play an important role in this situation. They take the control signals from Raspberry Pi
and provide the necessary drive current to the motor from the power supply.

In this project, the motor driver (L293D) is given with two control signals from Raspberry Pi through
GPIO Pins. As per the Python Program, the motor will rotate in either forward or reverse direction.

PROCEDURE:
1. Connect the HDMI cable between Monitor and Raspberry pi.
2. Connect the power supply and keyboard, mouse to Raspberry pi.
3. Open Raspberry Pi software and select Thonny.
4. Execute the commands and install the required packages.
5. Open new file and write a program in python.
6. Save the file with .py extension and upload the file.
7. Then connect the Relay sensor to the Raspberry Pi pins.
8. Then run the program.
9. Observe the Motor is rotating while detecting the sensor

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT


NAME: M VENKATESH DATE:

ROLL NO: 21EG104D35 PAGE NO:

Fig5.1: Sensor Interfacing with Motor using Relay

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT


NAME: M VENKATESH DATE:

ROLL NO: 21EG104D35 PAGE NO:

SOURCE CODE:
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.OUT)
GPIO.setup(17,GPIO.IN)
while(True):
if(GPIO.input(17)==0):
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
else:
GPIO.output(18,GPIO.LOW)
time.sleep(1)

RESULT:
Rotation of motor was observed by interfacing Motor with Raspberry Pi using relay.

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT

You might also like