if(a=='u')//Base Up
{while(a=='u')
{
servo2=1; //port B2
servo0=1; //port B1
servo1=0; //port B3
}
}
if(a=='o') //Gripper Open
{
for(i=0;i<50;i++)
{
servo5=1; //port B5=1
DelayMs(1);
DelayUs(250);
DelayUs(50);
DelayUs(250);
DelayUs(250);
servo5=0; //port B5=0
DelayMs(18);
DelayUs(200);
}
}
if(a=='p') //Gripper Close
{
for(i=0;i<50;i++)
{
servo5=1; //port B5=1
DelayMs(1);
DelayUs(500);
servo5=0; //port B5 =0
DelayMs(18);
DelayUs(500);
}
}
shahrul WROTE:You can try program servo using Timer Interrupt. It's aesier. To view program and the video, see here.
Han Giap WROTE:hi Shahrul,
thanks for the info... very appreciate it
i would like to know... is ur port A as input? n ur servo motor connected to port C (CCP)?
thanks
shahrul WROTE:RA7? not RA7. I use analog input on RA0.
If you want to use Push Button, use 2 push button. 1 for increments and 1 for decrements.
eg, if push button 1 is pressed, increments position servo,
if push button 2 is pressed, decrements position servo.
Users browsing this forum: No registered users and 0 guests