bhan1992
Member level 1
i duno why but when i compile this piece of code, the compiler says that there is a syntax error at line 11
can any1 tell me whats wrong with my code?
can any1 tell me whats wrong with my code?
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 #include <p18f452.h> #include <adc.h> #include <stdlib.h> #include <delays.h> int result, increment; void main (void) { OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_2_TAD & ADC_8ANA_0REF & ADC_INT_OFF ) TRISB = 0; while(1) { SetChanADC(ADC_CH0); ConvertADC(); while(BusyADC()); result = ReadADC(); if (result < 250) { PORTB = 0; //off the buzzer } else if (result >= 250 && result < 600) // slow beep { PORTB = 1; for(increment = 0; increment < 4; increment ++) //0.25 sec total delay { Delay10KTCYx(40); //0.1 seconds } PORTB = ~PORTB; } else if (result >= 600 && result < 850) // medium beep { PORTB = 1; for(increment = 0; increment < 4; increment ++) //0.25 sec total delay { Delay10KTCYx(20); //0.05 seconds } PORTB = ~PORTB; } else if (result >= 600 && result < 1025) // fast beep { PORTB = 1; for(increment = 0; increment < 2; increment ++) //0.15 sec total delay { Delay10KTCYx(20); //0.05 seconds } PORTB = ~PORTB; } } CloseADC(); }
Last edited by a moderator: