Beautiful. i didnt try the print the not number, because the first worked fine.
now that i have the physical printing semi-sorted, i moved onto the voltage calculation itself. it works perfectly fine, however, because i want to display to 0.1V, is there any method of 'rounding' that i could use to print a result (as seen by serial) of 2.55 to 2.6, and 2.54 to 2.5 for later integration onto the 7 segment displays?
here is the voltage snippit of coding
/*
result smoothing: http://www.arduino.cc/en/Tutorial/Smoothing
Voltage calculation: http://arduinotronics.blogspot.com.au/2011/03/monitoring-voltage-of-dc-battery-supply.html
*/
int VoltageIn = A5;
const int numReadings = 40;
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
void setup()
{
Serial.begin(9600); // initialize serial communication with computer:
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}
void loop()
{
total= total - readings[index]; // subtract the last reading:
readings[index] = analogRead(VoltageIn);// read from the sensor:
total= total + readings[index]; // add the reading to the total:
index = index + 1; // advance to the next position in the array:
if (index >= numReadings) // if we're at the end of the array...
index = 0; // ...wrap around to the beginning:
average = total / numReadings; // calculate the average:
Serial.println(average); // send it to the computer as ASCII digits
delay(1); // delay in between reads for stability
int val = analogRead(average); // read the value from the sensor
float volts = (average * 0.021965811965812); // calculate the ratio
Serial.println("Volts:");
Serial.println(volts); // print the value in volts
Serial.println("average value");
delay(400);
}