// C++ code
//THIS CODE IS USED TO BUILD A MULTIMETER
//SHOWING FREQUENCY
//VOLTAGE
//AMPERE
#include <Wire.h>
#include <IRremote.h>
#include <LiquidCrystal_I2C.h>
//ALL INPUT ARE DECLARED HERE
int inputPin =A0;
float voltage;
float resistor;
unsigned long frequency = 0;
bool display=false;
LiquidCrystal_I2C lcd(0x27,16,2);
void setup()
{
pinMode(inputPin,INPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(2,0);
lcd.print("NEWTECH CONGO");
lcd.setCursor(6,1);
lcd.print("SARL");
delay(2000);
lcd.clear();
}
void loop()
{
frequency=frequencymeter(inputPin);
voltage=voltmeter(inputPin);
displayValue(voltage);
}
//CALCULATE THE FREQUENCY
unsigned long frequencymeter(int InputPin){
unsigned long valIn= pulseIn(inputPin, HIGH);
frequency = 1000 / valIn;
return frequency;
}
//CALCULATE THE VOLTAGE
float voltmeter(float valIn){
float v1 = analogRead(valIn) ;
float valOut = v1 * 5 / 1023;
return valOut;
}
//DISPLAY VALUES ON SCREEN
void displayValue(float voltage ){
unsigned long prev = 0;
int intervall = 10;
if(millis()- prev > intervall ){
prev=millis();
lcd.setCursor(0,0);
lcd.print("INPUT: ");
lcd.setCursor(6,0);
lcd.print(voltage);
lcd.setCursor(10,0);
lcd.print(" V");
//lcd.print(frequency +" HZ");
// REFRESH SCREEN
display = !display;
if (display == false){
lcd.clear();
}
}
}