So I am trying to design a device that is able to determine whether any given coin cell battery has a voltage above or below a threshold of 1.0V. If its voltage is greater than or equal to 1.0V, then a green LED will light, otherwise a red LED will light.
I plan to achieve this using Arduino (if/else-if) and a simple circuit, but I have NO idea where to even begin. I know that I am hooking up the Arduino to a 12VDC adapter, but I don't know where to go from there.
Anyone out there who can help me/steer me in the right direction?
Read the voltage with analogRead()--store value in a variable---value will be read in integers between 0 and 1023 with 5V as reference, so if input voltage is 3V, value will be (3/5)*1023---then use if(value read>threshold), blink green LED---else blinkk red LED
Be careful not to connect the battery backwards. Or, add a 10K resistor between the battery and the Arduino's analog input. There are protection diodes inside the ATmega chip to protect against over-voltage or reverse voltage, but they can't handle a lot of current. A 10K series resistor will limit the current, so if you connect a battery backwards it will simply read zero.
I plan to achieve this using Arduino (if/else-if)...
Have you got that figured-out?
Note - If your only "output" is a pass/fail LED, your sketch doesn't actually need to make the voltage conversion... With the 10-bit / 5V analog-to-digital converter, 5V is 1023 and 1V is 1/5th of that (205). But if it was me, I'd leave the voltage conversion and Serial.pring() messages in the code just for future troubleshooting, etc.
Also, the 5V reference comes from the power supply. That means you might get slightly different readings if you switch between USB power and a different power supply.
Srijal97:
Read the voltage with analogRead()--store value in a variable---value will be read in integers between 0 and 1023 with 5V as reference, so if input voltage is 3V, value will be (3/5)*1023---then use if(value read>threshold), blink green LED---else blink red LED
You actually should multiply by 1024, not 1023 (but it only introduces a 0.1% error if you do it the other way).
If you are wanting to measure available capacity, apply a load while measuring the battery voltage.
The load current should be based on the max recommended current the battery can supply.
If the voltage is 80% at that current, the battery can be regarded as boarder line.