#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);  // Inisialisasi alamat I2C dan ukuran LCD

const int pirPin = 14;  // Pin sensor PIR

void setup() {
  Serial.begin(9600);  // Memulai komunikasi serial
    lcd.init();                      // Inisialisasi LCD
      lcd.backlight();                 // Aktifkan backlight LCD
        lcd.print("Program Counter:");
          lcd.setCursor(0, 1);
            lcd.print("Motion: Waiting...");

              pinMode(pirPin, INPUT);  // Set pin sensor PIR sebagai input
              }

              void loop() {
                uint32_t pcValue = (uint32_t) __builtin_return_address(0); // Dapatkan alamat program counter
                  lcd.setCursor(0, 0);
                    lcd.print("PC value: 0x" + String(pcValue, HEX));

                      int currentSensorValue = digitalRead(pirPin); // Baca nilai sensor PIR
                        lcd.setCursor(0, 1);
                          if (currentSensorValue == HIGH) {
                              lcd.print("Motion: Detected  ");
                                } else {
                                    lcd.print("Motion: None      ");
                                      }

                                        Serial.print("PC value: 0x");
                                          Serial.println(pcValue, HEX);
                                            Serial.print("Motion: ");
                                              Serial.println(currentSensorValue == HIGH ? "Detected" : "None");

                                                delay(1000); // Tunda selama 1 detik
                                                }