 # calculating voltage and printing significant numbers to lcd

Hi all,
New project to be completed and documented and uploaded once completed but I have a slight problem when I want to print calculated voltage to my LCD here’s an example:

``````#include <LiquidCrystal.h>
LiquidCrystal lcd(27, 29, 31, 33, 35, 37);

float Voltage = 0;                // VALUE
int VoltagePin    = A15;           // VOLTAGE DIVIDER

void setup() {
lcd.begin(16,2);
}

void loop() {
Voltage = map(Voltage, 0, 1023, 0.00, 55.00);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print(Voltage,2);
delay(500);
}
``````

This is just a snippet of the code that I have written, what I need is to display voltage ie, 19.23 but all It will display is whole numbers, 16.00, 17.00 ect. I am using a simple voltage divider to step down 50-5v, I know it will not give a high degree of accuracy, even .1 degree will be fine.
Thanks, Neo

Voltage = map(Voltage, 0, 1023, 0.00, 55.00);

The map function takes all integer arguments. It returns an integer value.

When the from and to range start at the same point, division is much faster than a function call the performs subtraction and division.

``````Voltage = Voltage * 55.0 / 1023.0;
``````