Programmer.C
Junior Member level 1
How Do I Use The Analog Pins In Pic 16f877a With MikroBasicPro
I'hv Tried the code below to use pin AN2 but it does not work
I'm working with RS232 Normally & I'hv not face any problems
But i can't read any analog signal with this code
I hope any body write me some code for reading an analog signal for example from a normal Potentiometer
I'hv Tried the code below to use pin AN2 but it does not work
I'm working with RS232 Normally & I'hv not face any problems
But i can't read any analog signal with this code
I hope any body write me some code for reading an analog signal for example from a normal Potentiometer
Code:
program Gen_Test
dim adc_rd as word
dim str_x as string [20]
main:
' Main program
ADCON1 = 0x00 ' Configure AN2 pin as analog
TRISA = 0xFF ' PORTA is input
UART1_Init(4800) ' initialize UART module
Delay_ms(100)
UART1_Write_Text("Ok")
while TRUE
adc_rd = ADC_Read(2) ' get ADC value from 2nd channel
WordToStr(adc_rd,str_x)
UART1_Write_Text(str_x)
Delay_ms(5000)
wend
end.