Hello all,
Hopeful someone can give me some advice on what I'm doing wrong. I'm attempting to sample voltage from pins 24 and 41. The pins are receiving 2x AA batteries as inputs but I'm never able to get a consistent reading on when the batteries are low. These batteries are also used to power on the board when not connected to a computer through USB via a boost converter. Currently I'm trying to sample the voltage from the batteries every minute.
#include <TimeLib.h>
int sampleVoltage;
int verifyVoltage;
time_t t = 0;
void setup() {
Serial.begin(9600);
while (!Serial && millis() < 5000) {
// wait for serial port to connect.
}
pinMode(24, INPUT_DISABLE);
pinMode(41, INPUT_DISABLE);
t = now();
}
void loop() {
if (minute(now()) - minute(t) >= 1){
sampleVoltage = analogRead(A17); //read pin 41
verifyVoltage = analogRead(A10);
Serial.print("Sample voltage = ");
Serial.println(sampleVoltage);
Serial.print("Verify voltage = ");
Serial.println(verifyVoltage);
t = now();
}
}
Hopeful someone can give me some advice on what I'm doing wrong. I'm attempting to sample voltage from pins 24 and 41. The pins are receiving 2x AA batteries as inputs but I'm never able to get a consistent reading on when the batteries are low. These batteries are also used to power on the board when not connected to a computer through USB via a boost converter. Currently I'm trying to sample the voltage from the batteries every minute.
#include <TimeLib.h>
int sampleVoltage;
int verifyVoltage;
time_t t = 0;
void setup() {
Serial.begin(9600);
while (!Serial && millis() < 5000) {
// wait for serial port to connect.
}
pinMode(24, INPUT_DISABLE);
pinMode(41, INPUT_DISABLE);
t = now();
}
void loop() {
if (minute(now()) - minute(t) >= 1){
sampleVoltage = analogRead(A17); //read pin 41
verifyVoltage = analogRead(A10);
Serial.print("Sample voltage = ");
Serial.println(sampleVoltage);
Serial.print("Verify voltage = ");
Serial.println(verifyVoltage);
t = now();
}
}