I am using Picchmium18F4550 with microchip v8.63 with the C18 compiler.
To enable the port to be set as input, I will connect an LDR to Port RA 0. Which is the following (I think)
TRISAbits.TRISA0 = 1; & Lt; = Set RA 0 as input Now I want the value of the LDR (if any lead is turned on), can I say:
< Code> int color ledge = portabits. Ra 0; And now there is the value / voltage of my leadership in the variable of type int.
Correct me if I am wrong.
It seems that you want to measure an analog voltage, in this case you should pin the AN0 , instead of RA0 . You should read section 21, but in short, you will need to configure the AD converter by using the registers ADCON0 , ADCON1 and ADCON2 , And read the results found on ADRESH: ADRESL . Note that you may be potentially read an LDR using digital input, but using it to check analog input is a bit more complicated, but more flexible .
Comments
Post a Comment