Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Smart Light with LDR-Controlled AC Dimmer

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Light with LDR-Controlled AC Dimmer

Circuit Documentation

Summary

This circuit is designed to control the brightness of an AC bulb using an Arduino UNO and an AC Dimmer Lamp Module. The brightness is adjusted based on the ambient light level detected by an LDR (Light Dependent Resistor) module. The Arduino reads the LDR value and adjusts the dimmer module accordingly to control the AC bulb's brightness.

Component List

AC Dimmer Lamp Module

Arduino UNO

AC Bulb

Module LDR

240v Power Source

Wiring Details

AC Dimmer Lamp Module

Arduino UNO

AC Bulb

Module LDR

240v Power Source

Documented Code

#define LDR_PIN A0  // Analog pin connected to LDR module AO pin
#define DIMMER_PIN 9  // PWM pin connected to Dimmer module PWM pin

void setup() {
  pinMode(DIMMER_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int ldrValue = analogRead(LDR_PIN);  // Read the LDR value (0-1023)
  Serial.print("LDR Value: ");
  Serial.println(ldrValue);

  // Map the LDR value to a PWM value (0-255)
  int pwmValue = map(ldrValue, 0, 1023, 0, 255);
  analogWrite(DIMMER_PIN, pwmValue);  // Write the PWM value to the dimmer module

  delay(100);  // Small delay to stabilize readings
}

This code reads the value from the LDR module and maps it to a PWM value to control the brightness of the AC bulb through the dimmer module. The analogRead function reads the LDR value, and the analogWrite function adjusts the dimmer module's output accordingly. The Serial functions are used for debugging purposes to print the LDR values to the serial monitor.