Professional Documents
Culture Documents
Lab11 Report
Lab11 Report
servo motor
Home Task:
Continuously rotate a servo motor from 45o to 135o. Consider the minimum and
maximum angle of motor 0o and 180o
.
//Non-Inverted
PWM
TCCR1B |= (1<<WGM13)|(1<<WGM12)|(1<<CS11);//Prescaler=16 Mode
14(Fast PWM)
ICR1=2499;
//Freq PWM=50Hz, Time Period = 20ms
DDRD = 0xFF;
//PWM generation on PortD5
while(1)
{
x = 124;
//1ms = 5% of 20ms pulse
OCR1A = x;
//0 degree rotation initially
_delay_ms(1000);
while(x<=249)
//2ms = 10% of 20ms Pulse
{
OCR1A=x;
_delay_ms(50);
x++;
}
}
}