Light Trigger

Difficulty: ● ○ ○ ○ ○

  • Did you know ?

    A Light Dependent Resistor (LDR) doesn’t just detect brightness — it can respond fast enough to sense the flicker of a candle or the passing of a shadow, making it usable in basic motion detection and even light-based Morse code systems.

No products found in parts_required metafield

How It Works ?

LDR senses ambient light → analog value read on GPIO7
Potentiometer on GPIO4 sets sensitivity threshold
When light drops below the threshold → white BRG LED (on pins 9, 6, 42) turns on
When light is above threshold → LED stays off
All controlled in real time, no button needed

GENESIS

Connection Guide

Snap your modules as shown above, copy the code into the Arduino IDE and Click upload

example.ino
#define LDR_PIN 7
#define POT_PIN 4

#define RED_PIN 6
#define GREEN_PIN 42
#define BLUE_PIN 9

void setup() {
  Serial.begin(115200);

  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
}

void loop() {
  int ldrValue = analogRead(LDR_PIN);     // LDR value: 0-4095
  int potValue = analogRead(POT_PIN);     // Pot controls threshold: 0-4095

  if (ldrValue < potValue) {
    // Light is lower than threshold: turn LED ON (white)
    digitalWrite(RED_PIN, HIGH);
    digitalWrite(GREEN_PIN, HIGH);
    digitalWrite(BLUE_PIN, HIGH);
  } else {
    // Too much light: turn LED OFF
    digitalWrite(RED_PIN, LOW);
    digitalWrite(GREEN_PIN, LOW);
    digitalWrite(BLUE_PIN, LOW);
  }

  delay(50);
}