// Lesson #15 - Servo Example

unsigned int adcData; // 10 bit number

unsigned int i;

void main() {

TRISB.B0 = 0; // Servo output

TRISA.B0 = 1; // Analog input

ADC_Init();

while(1){

adcData = ADC_Read(0);

PORTB.B0 = 1; // Rising edge of pulse

Delay_us(750); // Minimum pulse is .75 ms

for(i=0; i<adcData; i++)

{

Delay_us(2);

}

PORTB.B0 = 0; // Falling edge of pulse

Delay_us(20000);

}

}