Hello. I am very new to PIC programming. I am using MikroC compiler for PIC. The problem I have is:
I have a distance sensor, which will give me a range of voltages from 0 to 3 Volts. I need to get this value as a float variable in the program, so that I can use it in my C program. How do I work with Analog inputs? I think I should connect sensor to the RA0, for example. Then I set TRISA.F0=1 (declare as input). What should I do next? How to read the sensor data into variable of float type? I know that I should somehow tell the PIC that it is analog input, not digital.
Any advise would be appreciated.
Thank you,
Gtofig
I have a distance sensor, which will give me a range of voltages from 0 to 3 Volts. I need to get this value as a float variable in the program, so that I can use it in my C program. How do I work with Analog inputs? I think I should connect sensor to the RA0, for example. Then I set TRISA.F0=1 (declare as input). What should I do next? How to read the sensor data into variable of float type? I know that I should somehow tell the PIC that it is analog input, not digital.
Any advise would be appreciated.
Thank you,
Gtofig