#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int potPin = A0;
const int ledPin = 2;
const float resistorValue = 100.0;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(ledPin, OUTPUT);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("");
}
void loop() {
int sensorValue = analogRead(potPin);
float voltage = sensorValue * (5.0 / 1023.0);
float current = voltage / resistorValue;
float power = voltage * current;
if (voltage > 4.0) {
digitalWrite(ledPin, LOW);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("LED ON");
} else {
digitalWrite(ledPin, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("LED OFF");
}
Serial.print("VOLT: ");
Serial.print(voltage, 2);
Serial.println("V");
Serial.print("ARUS: ");
Serial.print(current, 4);
Serial.println("A");
Serial.print("DAYA: ");
Serial.print(power, 4);
Serial.println("W");
delay(1000);
}