Friday, May 20, 2016

ESP8266 - Arduino - AC MAINS Dimmer - MPDMv4

--------------------------------------------------- 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.

    For any new orders/requests please feel free to use as usual: tech (at) 
    MPDMv4 Boards are also available on Tindie: AC MAINS Dimmer - MPDMv4


For today we have a short but comprehesive Tutorial on how to drive the MPDMv4 AC MAINS Dimmer board using the Arduino IDE:

Arduino IDE code example for the Youtube Video Tutorial:


 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);

Creative Commons License MPDMv4 by is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.