e.hamza
Newbie level 5
i am supposed to control a servo motor movement using this code through the resistance change of a potentiometer
am using a pic 16f877A and ccs pic compiler
The code i've reached so far is
void main() {
int value,x1;
setup_adc_ports(ALL_ANALOG); setup_adc(ADC_CLOCK_INTERNAL); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE);
while (1) { set_adc_channel(0); delay_us(10);
value=read_adc();
x1 = value +1000 ;
output_high(PIN_b0); delAY_us(x1); output_low(PIN_b0); delay_ms(20); } }
any ideas guys ?please :S
am using a pic 16f877A and ccs pic compiler
The code i've reached so far is
void main() {
int value,x1;
setup_adc_ports(ALL_ANALOG); setup_adc(ADC_CLOCK_INTERNAL); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE);
while (1) { set_adc_channel(0); delay_us(10);
value=read_adc();
x1 = value +1000 ;
output_high(PIN_b0); delAY_us(x1); output_low(PIN_b0); delay_ms(20); } }
any ideas guys ?please :S