Ordered before 2 pm on working days = shipped the same day 30-day reflection period 1-year warranty
← Back to overview

Wiring diagram and code example

How to connect the PWM to Voltage converter module 0-10V to an Arduino UNO or ESP32, with an example sketch you can upload straight away.

PWM to 0-10V Voltage Converter Demo

This project demonstrates how to generate an analog control voltage (0-10V) using an Arduino PWM output. The Arduino outputs a varying PWM signal on pin 9, which the module converts into a proportional DC voltage at the VOUT terminal. Open the Serial Monitor to observe the current PWM duty cycle as the output sweeps up and down.

Wiring diagram: PWM to Voltage converter module 0-10V on an Arduino UNO
Wiring diagram · Click to enlarge
Connection table: PWM to Voltage converter module 0-10V on an Arduino UNO
Connection table · Click to enlarge
PWM_to_0_10V_Voltage_Converter_Demo.ino · compiled and verified
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : PWM to 0-10V Voltage Converter Demo
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : PWM naar Voltage converter module 0-10V
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// PWM to 0-10V Voltage Converter Demo

const int pwmPin = 9;

void setup() {
  pinMode(pwmPin, OUTPUT);
  Serial.begin(115200);
  Serial.println(F("PWM to Voltage Converter initialized."));
}

void loop() {
  // Ramp up output voltage (0% to 100% duty cycle)
  Serial.println(F("Ramping voltage up..."));
  for (int duty = 0; duty <= 255; duty += 5) {
    analogWrite(pwmPin, duty);
    Serial.print(F("Duty cycle: "));
    Serial.print((duty * 100) / 255);
    Serial.println(F("%"));
    delay(50);
  }
  
  delay(1000);

  // Ramp down output voltage (100% to 0% duty cycle)
  Serial.println(F("Ramping voltage down..."));
  for (int duty = 255; duty >= 0; duty -= 5) {
    analogWrite(pwmPin, duty);
    Serial.print(F("Duty cycle: "));
    Serial.print((duty * 100) / 255);
    Serial.println(F("%"));
    delay(50);
  }
  
  delay(1000);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

ESP32 PWM to 0-10V Voltage Converter Demo

This project demonstrates converting a digital PWM signal from the ESP32 into an analog 0-10V control voltage using the PWM-to-Voltage converter module. The module is powered by an external 12V DC supply and controlled via GPIO 18. The sketch sweeps the PWM duty cycle from 0% to 100%, generating an analog output ranging from 0V to 10V (ideal for PLCs, VFDs, or industrial dimmers).

Wiring diagram: PWM to Voltage converter module 0-10V on an ESP32 DevKit V1
Wiring diagram · Click to enlarge
Connection table: PWM to Voltage converter module 0-10V on an ESP32 DevKit V1
Connection table · Click to enlarge
ESP32_PWM_to_0_10V_Voltage_Converter_Dem.ino · compiled and verified
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 PWM to 0-10V Voltage Converter Demo
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : PWM naar Voltage converter module 0-10V
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// PWM to 0-10V Converter Module Demo with ESP32
// Connect GPIO 18 to PWM input and external 12V DC to module VIN

const int pwmPin = 18;

void setup() {
  Serial.begin(115200);
  pinMode(pwmPin, OUTPUT);
  Serial.println("ESP32 PWM to 0-10V Converter Demo Started");
}

void loop() {
  // Sweep output from 0V up to 10V in steps
  for (int duty = 0; duty <= 255; duty += 25) {
    analogWrite(pwmPin, duty);
    float expectedVoltage = (duty / 255.0) * 10.0;
    
    Serial.print("PWM Duty: ");
    Serial.print(duty);
    Serial.print("/255 | Approx Output: ");
    Serial.print(expectedVoltage, 1);
    Serial.println(" V");
    
    delay(1000);
  }
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online