Source: https://mokxi.com/learn/arduino-eurorack-cv-quantizer
Updated: 2026-10-05

Learn

# An Arduino Eurorack CV quantizer with a PWM DAC

Advanced

Written by the Mokxi team, updated October 5, 2026

Start building free Open the editor

Or see every lesson.

- 261 parts on the bench
- 31 boards running now
- 1.00x real time, on every board

Press Run, then turn the CV knob and watch the steps

Turn the CV knob and watch the steps on the scope. Slide the switch for sample and hold and press the gate button.

Modular synth players build modules as often as they buy them, and an Arduino is a common brain for the digital ones: quantizers, sequencers, clock dividers and LFOs. Open designs such as the Ardcore show how far one small board can go. The skills underneath are the same few: read a control voltage, decide something, and put a voltage back out.

The circuit above is a CV quantizer on an Arduino Nano in Mokxi. A knob stands in for the control voltage coming from another module, the sketch snaps it to the nearest note of a scale, and the output comes out at one volt per octave from a PWM pin and a filter, with the scope showing every step. A button stands in for a gate input, and a slide switch turns on sample and hold.

What is not simulated, up front: real Eurorack voltages. Modules run on plus and minus 12 volts and control voltages can swing past what an Arduino pin survives, so a real module scales and clamps every input and buffers and scales its output with op-amps. The quantizing, the timing and the DAC run for real here, and those are the parts you keep.

## One volt per octave

Most synth oscillators follow the one volt per octave standard: raise the control voltage by a volt and the pitch goes up an octave, so each semitone is a twelfth of a volt, about 83 millivolts. A quantizer’s job is to take any voltage and snap it to the nearest allowed note, so a wandering CV plays in key.

Over the Nano’s 0 to 5 volts that is five octaves, 60 semitones. The sketch reads A0, finds the nearest semitone, and if the scale does not allow it, looks one step either way for the nearest note that is allowed.

## A DAC from a PWM pin and a filter

An Arduino Nano has no DAC, but a PWM pin and a low-pass filter make a decent one. The sketch sets Timer 1 to a 10-bit fast PWM at 15.6 kHz on D9, far above audio, and a 4.7k resistor into a 1 microfarad capacitor averages it into a steady voltage. 1023 counts is 5 volts, so a semitone is about 17 counts, fine enough for pitch.

Put both scope channels on it to see the trade-off: channel 2 is the raw PWM and channel 1 the smoothed output. A bigger capacitor gives less ripple and slower steps; a smaller one, faster steps and more ripple. Real modules usually follow the filter with an op-amp buffer, and many use a dedicated DAC chip instead.

Timer 1 as a 10-bit DAC, from the example sketch

## Scales and roots

The scale is twelve bits, one per note from C to B. A 1 lets a note through: the major scale is C, D, E, F, G, A and B, the minor pentatonic five notes, and chromatic all twelve. ROOT shifts the scale to another key. Both are in the config block, along with FULL_SCALE, which you trim with a meter so each octave is exactly a volt on your own module.

## Gates, triggers and sample and hold

Every new note sends a 10 millisecond pulse on D8, a trigger output another module can use to fire an envelope. Slide the mode switch and the module becomes a sample and hold: the output only changes on the rising edge of the gate input, so a slowly moving CV becomes a stepped melody in time with a clock.

A gate from another module is a clean edge. The button standing in for it bounces, so the sketch ignores the gate for 20 milliseconds after each edge. On a real module the gate input goes through a transistor or comparator stage that protects the pin.

## Reading the scope

Turn the CV knob slowly from one end to the other. On a plain voltage divider the scope trace would rise in a smooth ramp. Here it climbs in flat steps, one per note the scale allows, and the gaps between steps are uneven because a major scale has whole tones and half tones. Change SCALE to chromatic and every step is the same height, about 83 millivolts; change it to the minor pentatonic and the steps get fewer and taller.

Each step also shows the filter at work: the edge is a curve, not a cliff, because the capacitor takes a few milliseconds to charge to the new voltage. That settling time is why a module that has to slew quickly between notes uses a smaller capacitor, a second filter stage, or a DAC chip. For a quantizer feeding an oscillator, a few milliseconds is short enough that the note lands where you expect it.

## From the simulator to the rack

Test the logic here, then build the analog front end on the bench: input scaling and protection, the output op-amp that turns 0 to 5 volts into the range your oscillators expect, and power from the rack’s 12 volt rails through a regulator. Those parts depend on your design, and Mokxi does not model Eurorack power.

## Questions

Can an Arduino output control voltage?

Yes, through a DAC chip or a PWM pin with a low-pass filter, as in the example. For Eurorack levels, follow it with an op-amp to buffer and scale the output.

Is it safe to plug Eurorack CV into an Arduino pin?

Not directly. Eurorack signals can go negative or above 5 volts. Scale and clamp every input with a divider and protection diodes or an op-amp first.

How accurate is a PWM DAC for pitch?

At 10 bits over 5 volts each count is about 5 millivolts and a semitone about 83, so it is fine for a quantizer. Trim FULL_SCALE with a meter so each octave is exactly a volt.

Does Mokxi simulate my synth?

It simulates the Arduino, the filter and the scope, not an oscillator or Eurorack power. The output voltage you see is the one a real module would put out before its op-amp stage.

Related

## Keep going

PWM: Faking an Analog Voltage on a Digital Pin DIY Stream Deck and Camera Slider With Arduino DIY Rhythm Game Controller: Guitar and Dance Pad The CV quantizer project: code, parts and wiring Advanced The Arduino Nano in Mokxi The oscilloscope part Make a free account to save your build The project page, with the full sketch Advanced

Sources

## Where the facts on this page come from

- Arduino Eurorack projects: open modules and libraries
- Ardcore: an open, Arduino-compatible Eurorack module
- Arduino: secrets of PWM and the timers

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
