hello guys anybody can help me to complate this code?
#include<16F877A.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay (clock=20000000)
#use rs232(baud=19200,xmit=PIN_C6,rcv=PIN_C7)
#include <stdlib.h>
#include <input.C>
#use fast_io(B)
#use fast_io(D)
#org 0x1F00,0x1FFF{}
#opt 9
void main(){
//define your variables here;
int16 time;
long a;
//set_tris for servo pin here;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
printf("Program Starts!!!\n\r");
while(TRUE){
delay_ms(1);
//////////setting the US sensor////////
set_tris_b(0b00000000);
output_high(US);
delay_us(5);
output_low(US);
set_tris_b(0b01000000);
/////////////////////////////////////////
////////////*calculating the duration////
delay_us(500);
while (!input(US)){ };
set_timer1(0);
while (input(US)){ };
time = get_timer1();
delay_us(5);
///////////calculating the distance in cm's/////
a=(long)((float)time/100.034);
printf("%lu\n\r",a);
/////////////////////////////////////////////////
if ("condition1"){ //set your condition according to position of the ball
//do nothing
}
else if ("condition2"){ //set your condition according to position of the ball
//CW-OR-CCW
calculate your servo duty with proportional and derivative gains according to distance
}
else if ("condition3"){ //set your condition according to position of the ball
//CCW-OR-CW
calculate your servo duty with proportional and derivative gains according to distance
}
printf("-----duty=%lu\n\r",duty);
for(i=0;i<10;i++)
{
output_high(SERVO);
delay_us(duty);
output_d(0);
delay_ms(20);
}
//delay_ms(100);
}
}