Introduction: Arduino - MPDMv4 - Universal AC MAINS Dimmer

----------------------------- DISCLAIMER -----------------------------

WARNING!! You will play with LIVE MAINS!! Deadly zone!!

If you don't have any experience and are not qualified for working with MAINS power I will not encourage you to play arround!. The author take no responsibility for any injury or death resulting, directly or indirectly, from your inability to appreciate the hazards of household mains voltages.

The circuit diagrams are as accurately as possible, but are offered with no guarantees whatsoever.

There is no guarantee that this design meets any Rules which may be in force in your country so please check before your local rules/regulations.


As anybody else with and interest about AC Dimmers, I was also looking for the easiest and safest way to interface my Arduino MCU with a AC MAINS Lightbulb and to be able to do smooth, flicker-free Dimming control for my lights.

After more that a year of experimenting with AC Dimming , I think I can come with a conclusion: the new MPDMv4 Universal AC MAINS Dimmer Module.

I don't know if is out there a easier to use AC Dimmer module, but this one definitelly is very easy to use and control. It is a voltage controlled unit and it contains onboard all the necessary functions (Phase detection, Zero Crossing detection, Sync, etc) to make your AC Light Dimming experience way simpler than before, in both ways, software programming and also wiring.

Step 1: What Do You Need

Step 2: Setup & Wiring

As you can see in the picture above, wiring is very simple:

  • Connect MAINS line wires to the corresponding AC MAINS input connector:
    • LIVE (BROWN)
    • Neutral (BLUE))
  • Connect the Lightbulb to the AC MAINS Output connector
  • Connect your Arduino Board to the Control connector:
    • VCNT - Control pin -> Arduino PWM output pin (YELLOW wire)
    • VCC - 3.3V (or 5V, depending on your Arduino Type you use) (RED wire)
    • GND - Ground connection from your Arduino Board (BROWN & ORANGE wire)

Step 3: Software

As you can see in the code example below, because all the MCU and Interrupts intensive fancy stuff (Phase detection, Zerocrossing Detection, Sync, etc) are all done at the MPDMv4 Universal AC Dimmer Board level, the Arduino software side is deadly simple and without any kind of overhead added by the Dimming processing functions:

Dimmer This simple Sketch demonstrates the sending data from the computer to the Arduino board, in this case to control the brightness of MPDMv4 AC MAINS Dimmer. The data is sent in individual bytes, each of which ranges from 0 to 255. Arduino reads these bytes and uses them to set the VCNT brightness command . The circuit: MPDMv4 Board attached from digital pin 3 to ground. Serial connection to Processing, Max/MSP, or another serial application created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald modified 14 Apr 2016 by TJ for AC MAINS Power Dimmer MPDMv4 Driver This example code is in the public domain. */
const int vcntPin = 3;      // the pin that the MPDMv4 VCNT pin is attached to
void setup()
  // initialize the serial communication:
  // initialize the VCNTPin as an output:
  pinMode(vcntPin, OUTPUT);
  // set default brightness value
  analogWrite(vcntPin, 230);
void loop() {
  byte brightness;

  // check if data has been sent from the computer:
  if (Serial.available()) {
    // read the most recent byte (which will be from 0 to 255):
    brightness = Serial.parseInt();
    Serial.print("Command received : ");
    // set the brightness of the LED:
    analogWrite(vcntPin, brightness);


I have only one conclusion: Probably the simplest and easiest to use AC MAINS Dimmer Board available. I am looking forward for your feedback about :)

For more details you can see the related AC MAINS Dimming Articles/ Videos:

The MPDMv4 Board is available also on Tindie:


ThomasK19 (author)2016-05-20

The source does not tell what "mains" means. In Europe you have 230V AC and in the States it's 110V AC. Now the opto-coupler for phase detection is directly coupled to mains via 2x66k Ohms. I have no figures about what coupler is used, but if it's calculated for 110V any implementation in Europe would need double the resistance.

TrackerJ (author)ThomasK192016-05-20

If you read the related article you will see that it's about 240VAC/50Hz EU MAINS. And it's working very well also on 110VAC/60Hz US MAINS. Hence the name "Universal"

ThomasK19 (author)TrackerJ2016-05-20

Thanks for the clarification :-)