Hi friends,
I want to know how to convert an obtained double or float value into a value with only ONE decimal places . ( ex. 230.0 )
Currently what i get as the output is something like 230.00 . I don't need two decimal points, I want only one .
I'm a newbie to programming . So please be kind enough to modify my code, or give me an example .
Thanks.
Dileesha.
My code for arduino is as below
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
#include <LiquidCrystal.h>// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(10, 9, 8, 7, 6, 5);
void setup()
{
Serial.begin(9600);emon1.voltage(2, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(3, 8.65); // Current: input pin, calibration.
lcd.begin(16, 2);
// pinMode(led,OUTPUT);
// digitalWrite(led, HIGH);
lcd.clear();
// Print a message to the LCD.
// lcd.print("Volt Amp Watt");
lcd.setCursor(0, 0);
lcd.print("Version 2.4 ");
delay(2000);lcd.setCursor(0, 0);
lcd.clear();
lcd.print("Amps");}
void loop()
{
emon1.calcVI(200,1000); // Calculate all. No.of half wavelengths (crossings), time-out
emon1.serialprint(); // Print out all variables
lcd.setCursor(6, 1);
double Irms = emon1.calcIrms(1480); // Calculate Irms only
lcd.print(Irms); // Irms
}
PLEASE NOTE : I also attached the complete EmonLib library i used as in a ZIP file . That zip folder contains both .CPP file and .H file .
EmonLib.zip (5.68 KB)