@HazardsMind,
I am running this code right now and measuring voltage and getting the print outs:
int temp;
void setup()
{
Serial.begin(9600);
}
void loop()
{
temp=getBandgap(); // <=========== YOU CAN LEAVE THESE OR DELETE THEM . These statement are just a test.
Serial.println(temp); //<============
delay(5000); // <============
}
int getBandgap(void) // Returns actual value of Vcc (x 100) 415 = 4.15v
{
int raw = analogRead(0); // <========= NJ9A ==== CHANGE THIS TO A15 !
int results = map(raw,0,1096,0,500); // scale voltage to 0-500
float myfloat;
float sensorCalbrate = 1.095845;
int battv=results;
int temp=battv;
int x;
int y;
float z;
float batteryV;
x = battv;
y = 100.00;
// y now contains 0, ints can't hold fractions
z = (float)x / y; // z now contains .5 (you have to use 2.0, not 2)
batteryV=z*sensorCalbrate;
Serial.println(z,4);
Serial.println(batteryV,4);
temp = (batteryV*100);
battv== (int) temp ; // now i is 3
Serial.println(temp);
battv=temp;
results=temp;
return results;
}
I admit this doesn't make any sense but I didn't change it because it doesn't effect anything.
int battv=results;
int temp=battv;
BATTV.txt (138 Bytes)