0% found this document useful (0 votes)
6 views4 pages

C_Experiment_8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

C_Experiment_8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

experiment - 8

Aim – Position control of Servo Motor with Raspberry pi.

Objective –

1. Operating an actuator with a Raspberry Pi to control the actuator position.

Components Required –

1. Raspberry Pi (any model with GPIO pins)


2. RPi Power Adapter
3. SD Card
4. Actuator (Servo/DC Motor)
5. Jumper Wires (Male to Female and Male to Male)
6. Breadboard (optional)

Circuit Diagram and Theory –

Circuit Diagram:

Department of Mechatronics Engineering


Page 1 | 4
Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

Figure. 1: Circuit Diagram for Servo Motor with RPi.

Steps:

1. Wiring:

 Connect the servo motor to the Raspberry Pi using jumper wires. Servo motors typically have
three wires:
a) Brown/Black: Connect to a ground (GND) pin on the Raspberry Pi.
b) Red: Connect to a 5V pin on the Raspberry Pi.
c) Orange/Yellow: Connect to a GPIO pin on the Raspberry Pi (e.g., GPIO17 - Pin 11).
 Here's a basic wiring diagram:

Code:

You'll need to write a Python script to control the servo motor's position. The script will use the RPi
GPIO library to generate PWM (Pulse Width Modulation) signals to control the servo's angle.

Department of Mechatronics Engineering


Page 2 | 4
Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

Department of Mechatronics Engineering


Page 3 | 4
Course Code - MC1030Course Name - Arduino, IoT FAB Lab.

a) Run the Code:


 Save the Python script on your Raspberry Pi (e.g., as servo_control.py). Open a terminal and
navigate to the directory where you saved the script.
 The script will rotate the servo motor to different angles (0, 90, and 180 degrees) in a loop. You
can adjust the angles and timing as needed.
 Remember that servo motors may have specific operating voltage and current requirements.
Ensure that your Raspberry Pi and servo motor are properly powered and connected. Always
follow safety precautions when working with electronic components.

Additional Tasks –

Conclusions –

Department of Mechatronics Engineering


Page 4 | 4

You might also like