Gopi Vh
Newbie level 4
- Joined
- Jan 10, 2015
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 44
help me out i am not able to read the adc value .
i am reading adc value from analog channel 2
here my code is there
i am reading adc value from analog channel 2
here my code is there
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 /* adc conversion*/ unsigned char adc_value; unsigned char sensor; char *text="00000"; const gas_max = 642; void main() { ADCON0 =0x08; ANSEL =0b00000110; ADRESH =0; ADRESL =0; CMCON = 7; GPIO=0; //clear all pins TRISIO.B2=1; //ip TRISIO.B1=0; //op TRISIO.B0=0; //op TRISIO.B5 =0; //op while(1) { adc_value=adc_read(2); adc_value= (((unsigned int)ADRESH<< 8)| (ADRESL)); sensor =(553 - (adc_value-61)); delay_ms(200); if(sensor < gas_max) { GPIO.B1=1; //green led; delay_ms(20); } else { delay_ms(20); GPIO.B0 = 1; //red led GPIO.B5 = 1; //buzzer } } }
Last edited by a moderator: