AC Lamp Dimmer

Control light intensity of 230V AC lamp via Bluetooth using Arduino

AC Lamp Dimmer

This page explains how to modify an AC lamp to control its brightness from Android phone via Bluetooth.

Materials needed:
- AC Lamp with dimmer control
- 4x 1N4004 diodes
- Photoresistor LDR07 300V
- Yellow LED
- 1k resistor
- 100k resistor
- shrink tube
- soldering iron + solder
- Arduino UNO (or similar) + USB cable for it
- DC adapter for Arduino
- BlueSMiRF module
- wires
- Android phone with RoboRemo app installed


Working with high voltage can kill you or burn your house, etc. Please be very careful!
We hope that nothing bad will happen, but if you try to build and / or use this circuit,
the only one responsible for that is you.


I got a lamp that already had dimmer and I identified the components. The original lamp circuit is the circuit that was inside the lamp. It has an ON/OFF switch that turns the full brightness ON/OFF. When the main switch is OFF, the dimmer can be used. The brightness is adjusted using a variable 500k resistor. SW1 is also inside the variable resistor, so it first turns ON the dimmer when you rotate.
To control the brightness from Arduino, I need to somehow modify that 500k resistance. Also I need to electrically insulate the Arduino from the rest of the circuit. One option would be to use a motor to rotate the dimmer knob, however that requires mechanics and is hard to fit inside the lamp body. The other option, which I used in this project, is to attach an Arduino-controlled variable resistor in parallel to the original one. I found a Light Dependent Resistor (LDR) labeled LDR07 300V DC. I assume it requires DC so we also added a 4-diode bridge rectifier.

I put the LDR together with a yellow LED and 1k resistor inside a shrink tube, forming a DIY optocoupler :D


Then I fitted the circuit inside the lamp and made some tests. I found that with PWM 1 out of 255 I got full brightness, so I added the 100k Raux, to decrease the sensitivity of the "optocoupler".

Now the lamp cirucit looks like this:


Below are the steps required to build this project:


Remove (unplug) Lamp from the mains. Make sure it is NOT connected before disassembling to modify circuit.

Build the DIY optocoupler according to the project description.

Modify the lamp ciruit according to the schematic in the project description, fit it inside the lamp and put back together the lamp. Now only the 2 wires form the optocoupler input must get out of the lamp.

Upload the code to your Arduino:

// Control LED ON/OFF and brightness(PWM)
// via Bluetooth using RoboRemo app

// Hardware setup:

// BT module   Arduino
// GND ------- GND
// VCC ------- 5V
// TX-O ------ pin0
// RX-I ------ pin1

//       LED
// GND----K|---[1k]---[Raux]---pin10

#define bluetooth Serial

int led = 10;

char cmd[100];
int cmdIndex;

boolean cmdStartsWith(char *st) {
  for(int i=0; ; i++) {
    if(st[i]==0) return true;
    if(cmd[i]==0) return false;
    if(cmd[i]!=st[i]) return false;;
  return false;

int brightness = 0;
int ledOn = 0;

void exeCmd() {
  if( cmdStartsWith("br ") ) { // example: if cmd is "br 100"
    brightness = atoi(cmd+3);  // brightness will be 100
    if(ledOn) {
      analogWrite(led, brightness);
  if( cmdStartsWith("on") ) {
    analogWrite(led, brightness);
    ledOn = 1;
  if( cmdStartsWith("off") ) {
    analogWrite(led, 0);
    ledOn = 0;
  if( cmdStartsWith("tog") ) { // toggle ON/OFF
    if(ledOn) {
      analogWrite(led, 0);
      ledOn = 0;
    } else {
      analogWrite(led, brightness);
      ledOn = 1;

void setup() {
  delay(500); // wait for bluetooth module to start

  bluetooth.begin(115200); // Bluetooth default baud is 115200
  pinMode(led, OUTPUT);
  analogWrite(led, 0);  // OFF
  ledOn = 0;
  cmdIndex = 0;

void loop() {
  if(bluetooth.available()) {
    char c = (char);
    if(c=='\n') {
      cmd[cmdIndex] = 0;
      exeCmd();  // execute the command
      cmdIndex = 0; // reset the cmdIndex
    } else {      
      cmd[cmdIndex] = c;
      if(cmdIndex<99) cmdIndex++;

In this example we use Hardware Serial. But Arduino UNO also uses Hardware Serial for programming, so when you program the Arduino, you need to disconnect the Bluetooth module, and to run the circuit, you need to disconnect the USB cable and connect the Arduino DC power supply.

Connect the Bluetooth module and optocoupler input pins to Arduino:


Connect your Arduino to the DC power supply.

Download the RoboRemo interface file:


Copy the interface file to your Android device, then import in RoboRemo using menu -> interface -> import.

Enjoy :)