#include<16f877a.h>
#fuses HS,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
const int16 rht_lft[7] = {1500, 1583, 1666, 1749, 1832, 1915, 2000};
void main()
{
int16 i;
int16 a;
char ser_com;
while(1)
{
ser_com = getc();
switch(ser_com)
{
case 0x31:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[0]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
case 0x32:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[1]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
case 0x33:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[2]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
case 0x34:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[3]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
case 0x35:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[4]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
case 0x36:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[5]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
case 0x37:
for(a=1;a<=50;a++)
{
output_high(PIN_D6);
delay_us(rht_lft[6]); //sending 5 volts to servo for pulse_width microseconds
output_low(PIN_D6);
delay_ms(20);
}
break;
}
}
}