eebhoi01
Advanced Member level 4
Hello Guys,
Im currently coding a project which involves reading an analog value ranging from 0 to 1.8V. How am I going to do this?
I tried this code:
float data;
void Analog()
{
data = ADC_Read(0); // adc read at AN0
data = (data/1023)*1.8; //1.8 is my maximum value
if (data > .5) { "DO SOMETHING"; }
else {DO NOTHING}
}
This is the part of my program where ADC works. My question is, is the ".5" right? or it should either be 1 or 0?
The decimal value is really important in my application, please help me out.
Best Regards,
Jay
Im currently coding a project which involves reading an analog value ranging from 0 to 1.8V. How am I going to do this?
I tried this code:
float data;
void Analog()
{
data = ADC_Read(0); // adc read at AN0
data = (data/1023)*1.8; //1.8 is my maximum value
if (data > .5) { "DO SOMETHING"; }
else {DO NOTHING}
}
This is the part of my program where ADC works. My question is, is the ".5" right? or it should either be 1 or 0?
The decimal value is really important in my application, please help me out.
Best Regards,
Jay