Hi everyone
Im kind of new in PIC , I want to control the servo motors with 2 buttons
for example if button 1 pressed the servo rotate 90 degree CW and then if button 2 pressed the servo rotate CCW 90 degree (back to the previous position)
I think it will be easy but im confusing at the parts of delay or pulse
can anyone send me the code plz...
thanks
There are tons of how-to guides online (and in this forum's archive) for implementing RC servo control on a PIC. But here are the basics:
RC servos require a PWM signal of about 50 Hz (doesn't need to be exact). The typical duty cycles are 1ms for maximum rotation in one direction and 2ms for maximum rotation in the other direction. IIRC, you won't be able to achieve that slow of a PWM frequency using the hardware PWM module. So you'll have to implement your own PWM in software using a timer.
hi everyone thanks for your help
actually I just want to rotate the servo motor 90 CW and then after 45 seconds 90 degree CCW (back to the same position) use just one button (if button pressed) here is my code but i dun know whether it will work or not here is my code:
if (BUTTON != 0)
for(i=0;i<45*5; i++) // for 45 seconds
{
RC3 = 1;
__delay_ms(1.5); // delay for 2 milliseconds
CLRWDT();