I am working on a project that monitors and tests a 24 V Lead acid battery,
Basically its a 24V setup,
the micro will at intervals connect a small load to a battery for a given period of time, after a small delay itll read the ADC and convert it to a voltage.
If the voltage is below a certain point I toggle an OP. Note PINB1 is set to 1 during initialisation. also read_adc(3) is a another function that reads the selected adc.
the conditional loop is like this:
v=(read_adc(3)*.0293); //Read ADC 3, and convert to voltage. V is a float.
if (v > = 22 )
PORTB |= (1<<PINB1); //Ensure PINB1 is on.
PORTB &= ~(1<<PINB1); //Turn B1 off.
Can you see any errors in the code it doesn't seem to be working.