#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
LiquidCrystal_I2C lcd2(0x27, 16, 2);
int photoCellPin = A0;
int val = 0;
int photoCellPinD = 0;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
lcd.print("hello, world!");
lcd2.init();
lcd2.backlight();
Serial.begin(9600);
pinMode(photoCellPin, INPUT);
pinMode(photoCellPinD, INPUT);
}
void loop() {
lcd.setCursor(0, 1);
lcd.print(millis() / 1000/60);
lcd.setCursor(8, 1);
lcd.print(millis() / 1000);
//wait for a second
//lcd2.setCursor(0,0);
//lcd2.print("Hello, From");
//lcd2.setCursor(0,1);
//lcd2.print("Arduino_uno_guy");
val = analogRead(photoCellPin);
Serial.println(val);
float voltage= val * (5.0 / 1023.0);
Serial.println(voltage);
lcd2.setCursor(0,0);
lcd2.print("Voltage = ");
lcd2.setCursor(10,0);
lcd2.print(voltage);
lcd2.setCursor(15,0);
lcd2.println("V");
lcd2.setCursor(0,1);
lcd2.print("Sensor = ");
lcd2.setCursor(10,1);
lcd2.println(val);
//if (digitalRead(photoCellPinD) == HIGH) { // Baca PIN 5
//Serial.println("Lampu Menyala"); // Nyalakan Led Merah
//} else {
//Serial.println("Lampu Mati"); // Matikan Led Mera
//}
}