"this code is suppose to take a input of <=5v analog voltage and convert it to digital in order to show on the screen how much voltage is left"
"is the code correct???? PLEASE HELP"
//Analog to Digital Voltage
const int anPin = 1; //sets pin 1 as analog reader
long anVolt, hold;
float val;//value of voltage
void setup(){
pinMode(anPin, INPUT);
}
void loop(){
for(int time = 0; true ; time++){ //x needs to be a number of time
// i.e. amount of time it will take the
//battery to die
anVolt = analogRead(anPin); //reads the voltage '0v' - '5v'
hold = (float)anVolt * .004888 ; //constant 5/1023
val = (float)hold * 2.4;//for the 12 volt measurement
delay(300000); //five minutes delay then reads battery voltage again
}
Serial.print("Amount Voltage Left ");
Serial.print(val);
}
cool, i changed that.. would the code work?.. also does the arduino need an output pin for the voltage to display?
if it's 204.. it would be 204*0.004888= roughly 1... then it would multiply by 2.4 which would equal 2.4 volts then that needs to show up on an lcd screen or something like that.