
Project Source Code
###
// Program to control Servo angular position using PIC18F4550 Microcontroller
// The on-time pulse for 0° position has been taken as 0.55ms
// Delay_ms() provides delay in milliseconds while Delay_us() provides delay in microseconds
unsigned int angle=0,i;
void cs_delay(unsigned int);
void main()
{
TRISB.F0=0;
while(1)
{
for(angle=0;angle<=180;angle+=45) // Loop to increase the angle by 45°
{
for(i=0;i<50;i++) // Loop to provide continuous train of pulse
{
LATB.F0=1; // Send high to control signal terninal
cs_delay(angle); // Call delay function
LATB.F0=0; // Send low to control signal terninal
Delay_ms(18);
}
}
}
}
void cs_delay(unsigned int count)
{
int j=0;
Delay_us(550); // Delay to move the servo at 0°
for(j=0;j<count;j++) // Repeat the loop equal to as much as angle
{
Delay_us(6); // Delay to displace servo by 1°
}
}
###
Circuit Diagrams
Project Components
Project Video
Source: How to interface Servo Motor with PIC Microcontroller- (Part 21/25)
Related projects
Real-Time CAN-Based Vehicle Monitoring System with PIC MCU
INTRODUCTION The Controller Area Network (CAN) is a robust vehicle communication bus standard that was primarily developed for automobile applications but has...
Motors & RoboticsEasy Way to Learn Robotics Using Microcontrollers: A Beginner’s Guide
The title, "Easy Way to Learn Robotics Using Microcontrollers," promises an accessible entry point for those curious about the exciting world of...
Motors & Robotics · PIC16F877AEfficient Sun-Following Robot: A Solar Tracker with Microcontroller Control
Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....
Motors & RoboticsInnovative Robotics: A Comprehensive Project Exploration
A DC motor functions as an electromechanical device, translating electrical signals into mechanical movements. The rotation of the motor correlates directly with...
Motors & RoboticsAdvanced Techniques for Fault Detection, Indication, and Protection in Induction Motors
1. INTRODUCTION The impact of microcontroller usage on our daily lives is remarkable. This versatile device is now prevalent in various control...
Motors & RoboticsExploring Versatility: GSM-Based Robotic Vehicle Technology
Introduction To Robotics The term 'Robot' remains elusive, defying a precise definition due to its evolving usage. Initially, it referred to humanoid...
