================================================================================
  Experiment 2: ESP32 LDR Light Intensity Monitoring (Serial Monitor)
================================================================================

FULL QUESTION:
Develop an ESP32 program to read light intensity using an LDR module and display the readings using serial communication.

SHORT QUESTION:
ESP32 LDR Light Intensity Monitoring using Serial Communication.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Experiment 2: ESP32 LDR Light Intensity Monitoring

## Objective
Read digital ambient light levels using an LDR sensor module and display the status via Serial Communication.

## Hardware Wiring
- LDR VCC -> ESP32 3V3
- LDR GND -> ESP32 GND
- LDR DO (Digital Output) -> ESP32 GPIO 34

## How to Run in Wokwi
1. Load `sketch.ino` and `diagram.json` into Wokwi.
2. Click **Start Simulation**.
3. View the **Serial Monitor** (115200 baud).
4. Click on the LDR sensor in Wokwi and adjust the Lux slider to toggle between BRIGHT and DARK.

================================================================================
SOURCE CODE FILES:
================================================================================

1. sketch.ino
--------------------------------------------------------------------------------
/*
================================================================================
IOT EXPERIMENT 02: ESP32 LDR Light Intensity Monitoring
================================================================================
Develop an ESP32 program to read light intensity using an LDR module and
display the readings using serial communication.
================================================================================
*/

// Short Description: Samples ambient light levels using an analog Light Dependent Resistor (LDR / photoresistor) on ESP32 GPIO 34 and outputs illumination status over Serial.

/*
README / BEFORE RUNNING:
- Prerequisites: Wokwi Simulator or ESP32 board with photoresistor / LDR module.
- Wiring / Pins: Connect LDR VCC to 3.3V, GND to GND, and Analog Out to ESP32 GPIO 34.
- How to Run: Open sketch.ino in Wokwi (simulate light change by clicking the LDR) or flash to hardware; open Serial Monitor at 115200 baud.
- Expected Behavior: Streams light detection status ('BRIGHT' / 'DARK') every 1 second based on ambient illumination.
*/

#define LDR_PIN 34

void setup() {
  Serial.begin(115200);
  delay(1000);
  pinMode(LDR_PIN, INPUT);
  Serial.println("LDR Monitoring Initialized.");
}

void loop() {
  int lightStatus = digitalRead(LDR_PIN);

  Serial.print("Light Status: ");
  if (lightStatus == LOW) {
    Serial.println("BRIGHT (Light Detected)");
  } else {
    Serial.println("DARK (No Light)");
  }

  delay(1000);
}
--------------------------------------------------------------------------------

2. diagram.json
--------------------------------------------------------------------------------
{
  "version": 1,
  "author": "IoT Lab",
  "editor": "wokwi",
  "parts": [
    { "type": "board-esp32-devkit-c-v4", "id": "esp", "top": 0, "left": 0, "attrs": {} },
    { "type": "wokwi-photoresistor-sensor", "id": "ldr1", "top": 0.3, "left": -159, "attrs": {} }
  ],
  "connections": [
    [ "esp:TX", "$serialMonitor:RX", "", [] ],
    [ "esp:RX", "$serialMonitor:TX", "", [] ],
    [ "ldr1:GND", "esp:GND.2", "black", [ "v0" ] ],
    [ "ldr1:VCC", "esp:3V3", "red", [ "v0" ] ],
    [ "ldr1:DO", "esp:34", "green", [ "v0" ] ]
  ],
  "dependencies": {}
}
--------------------------------------------------------------------------------
