Skip to content

Danny-Nosrati/Arduino-Light-Project

Repository files navigation

LED AC Dimmer Control Center

Control your 6 LEDs in series via AC Dimmer Module with a modern web interface!

Hardware Setup

Components Needed

  • Arduino board (Uno, Nano, Mega, etc.)
  • AC Dimmer Module (240V/8A)
  • 6 LEDs in series (or incandescent lamps)
  • Connecting wires
  • USB cable for Arduino

Wiring - IMPORTANT!

Arduino to AC Dimmer Module:

  • Dimmer Zero PinArduino Pin 2 (MUST be interrupt pin - D2 on Uno/Nano)
  • Dimmer DIM PinArduino Pin 9 (can be any digital pin)
  • Dimmer VCCArduino 5V
  • Dimmer GNDArduino GND

AC Dimmer to LEDs:

  • Connect your 6 LEDs in series to the AC dimmer module's output terminals
  • Connect AC input (120V or 240V) to dimmer's input terminals
  • ⚠️ WARNING: Handle AC connections with extreme care!

Arduino to Computer:

  • USB cable from Arduino to your laptop

Software Setup

Step 1: Install RBDdimmer Library

  1. Open Arduino IDE
  2. Go to: Sketch → Include Library → Manage Libraries
  3. Search for: "RBDdimmer"
  4. Click Install on "RBDdimmer by RobotDyn"
  5. Wait for installation to complete

Step 2: Upload Arduino Code

  1. Open led_controller.ino in Arduino IDE
  2. Select your Arduino board: Tools → Board
  3. Select the correct COM port: Tools → Port
  4. Click the Upload button (→)
  5. Wait for "Done uploading" message

Step 3: Open Control Center

  1. Open control_center.html in Google Chrome or Microsoft Edge
  2. Click "Connect to Arduino"
  3. Select your Arduino's COM port from the popup
  4. Click "Connect"

Using the Control Center

Connection

  • Connect to Arduino: Opens port selector
  • Disconnect: Closes serial connection
  • Green indicator: Connected and ready

Controls

  • Power Toggle: Turn LEDs ON/OFF
  • Brightness Slider: Adjust from 0% to 100%
  • ☀️ Sunrise Button: Automatically fade from 0→100% over 5 minutes

Status Display

  • State: ON/OFF status
  • Brightness: Current percentage
  • Mode: NORMAL or SUNRISE

Console

  • Shows all commands and responses
  • Color-coded: Green (sent), Blue (received), Red (errors)

Communication Protocol

Commands (PC → Arduino)

  • ON - Turn LEDs on
  • OFF - Turn LEDs off
  • BRIGHTNESS75 - Set brightness to 75% (0-100)
  • SUNRISE_START - Start 5-minute sunrise simulation
  • SUNRISE_STOP - Stop sunrise simulation
  • STATUS - Request current status

Responses (Arduino → PC)

  • STATUS:ON:75:NORMAL - LEDs ON at 75%, normal mode
  • STATUS:ON:45:SUNRISE - LEDs ON at 45%, sunrise mode active
  • SUNRISE:STARTED - Sunrise simulation started
  • SUNRISE:COMPLETE - Sunrise simulation finished

Troubleshooting

Cannot upload to Arduino

  • Close Arduino Serial Monitor (locks the port)
  • Check USB cable connection
  • Verify correct board and port selected

"RBDdimmer.h: No such file" error

  • Install RBDdimmer library (see Step 1 above)
  • Restart Arduino IDE after installation

Dimmer not working

  • Check Zero pin: MUST be on interrupt pin (D2 on Uno/Nano)
  • Verify wiring: Zero → Pin 2, DIM → Pin 9
  • AC power: Ensure AC dimmer has proper AC input
  • Load type: Works best with incandescent/resistive loads

Interrupt Pin Reference

Different Arduino boards use different interrupt pins:

  • Uno/Nano: Pin 2 (INT0), Pin 3 (INT1)
  • Mega: Pins 2, 3, 18, 19, 20, 21
  • Leonardo: Pins 0, 1, 2, 3, 7

If using a different board, change ZERO_CROSS_PIN in the code to match available interrupt pins.

LEDs flicker or unstable

  • AC dimmers work best with incandescent bulbs
  • Some LED bulbs may not be dimmable
  • Ensure proper load (not too low, not exceeding 8A)

Technical Details

  • Control Method: AC phase-angle control with zero-crossing detection
  • Library: RBDdimmer.h by RobotDyn
  • Interrupt Pin: Pin 2 (INT0 on Uno/Nano)
  • Control Pin: Pin 9 (digital)
  • Baud Rate: 9600
  • Brightness Range: 0-100%
  • Sunrise Duration: 5 minutes (300 seconds)

Safety Warning ⚠️

This project involves AC mains voltage (120V/240V) which can be LETHAL!

  • Only work on AC connections when power is OFF
  • Use proper insulation and enclosures
  • If unsure, consult a licensed electrician
  • Never touch AC connections while powered
  • This is for educational purposes only

Features

✨ Professional AC dimming control
🌅 5-minute sunrise simulation
🎨 Dark mode with premium UI
⚡ Real-time serial communication
🔌 Web Serial API (no drivers needed)
📊 Live status and mode indicators
🎯 RBDdimmer library integration


Enjoy your smart LED dimming system! 💡

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published