// Define the pin for the potentiometer and LDR
const int potentiometerPin = A0;
const int ldrPin = A1;

unsigned long previousMillis = 0;
const long interval = 1000; // 1 second interval

void setup() {
  // Start serial communication
  Serial.begin(9600);
}

void loop() {
  unsigned long currentMillis = millis();

  // Check if it's time to read and display values
  if (currentMillis - previousMillis >= interval) {
    // Save the last time you read the values
    previousMillis = currentMillis;

    // Read the value of the potentiometer (0-1023)
    int potValue = analogRead(potentiometerPin);

    // Map the potentiometer value to a range of 1 to 200
    int sensitivity = map(potValue, 0, 1023, 200, 1); // Ensure sensitivity is at least 1

    // Read the value of the LDR
    int ldrValue = analogRead(ldrPin);

    // Calculate the adjusted LDR value as a percentage
    float adjustedLDRValue = (float)ldrValue / sensitivity * 100.0;

    // Print the values to the serial monitor
    Serial.print("Potentiometer Value: ");
    Serial.print(potValue);
    Serial.print("\t Sensitivity (Mapped): ");
    Serial.print(sensitivity);
    Serial.print("\t Raw LDR Value: ");
    Serial.print(ldrValue);
    Serial.print("\t Adjusted LDR Value (%): ");
    Serial.println(adjustedLDRValue);
  }
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
pot1:GND
pot1:SIG
pot1:VCC
ldr1:VCC
ldr1:GND
ldr1:DO
ldr1:AO