nsw1216
Member level 3
I am trying to write a program to control the rotation of a servo motor using the C programming with the Microcontroller of AT89S52.
I have written a source code which ask the servo motor to rotate anti-clockwise. But no matter how i programmed it, it is also rotate clockwise only. My source code is attached below.
Anyone can help me to check for it and provide me some guidance on how to modify the source in order to make the servo motor rotate to the anti-clockwise.
Your help will be appreciated and welcome your comments or ideas on it. Thank you.
I have written a source code which ask the servo motor to rotate anti-clockwise. But no matter how i programmed it, it is also rotate clockwise only. My source code is attached below.
Anyone can help me to check for it and provide me some guidance on how to modify the source in order to make the servo motor rotate to the anti-clockwise.
Your help will be appreciated and welcome your comments or ideas on it. Thank you.
Code:
#include <reg51.h>
sbit Servo1=P1^0; //crystal frequency is 33MHz
bit on=1;
bit off=0;
void main()
{
int x,y;
Servo1=off;
for(x=0;x<20;x++)
{
Servo1=on;
for (y=0;y<500;y++)//250 for 0.5 ms
{;}
Servo1=off;
for (y=0;y<9500;y++)//10000
{;}
}
PCON=0xFF;
}