0% found this document useful (0 votes)
6 views2 pages

Arduino Code

Uploaded by

atrimansaha15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Arduino Code

Uploaded by

atrimansaha15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <PZEM004Tv30.

h>
#include <LiquidCrystal.h>
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

PZEM004Tv30 pzem(11, 12);

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

float pf = pzem.pf();
lcd.setCursor(4, 0);
lcd.print("WELCOME!");
delay(5000);

lcd.clear();
lcd.print("calculating...");
delay(3000);

lcd.clear();
lcd.print("without cap");
lcd.setCursor(0, 1);
lcd.print("PF: "); lcd.println(pf);
delay(5000);

if (pf < 0.95)


{
digitalWrite(8, HIGH);
pf = pzem.pf();

lcd.clear();
lcd.print("calculating...");
delay(3000);

lcd.clear();
lcd.print("adding 1 cap");
lcd.setCursor(0, 1);
lcd.print("PF: "); lcd.println(pf);
delay(3000);
}
if (pf < 0.95)
{
digitalWrite(9, HIGH);
pf = pzem.pf();

lcd.clear();
lcd.print("calculating...");
delay(3000);

lcd.clear();
lcd.print("adding 2 cap");
lcd.setCursor(0, 1);
lcd.print("PF: "); lcd.println(pf);
delay(3000);
}
if (pf < 0.95)
{
digitalWrite(10, HIGH);
pf = pzem.pf();

lcd.clear();
lcd.print("calculating...");
delay(3000);

lcd.clear();
lcd.print("adding 3 cap");
lcd.setCursor(0, 1);
lcd.print("PF: "); lcd.println(pf);
delay(3000);
}

You might also like