Hand-controlled CV sequencer firmware for mudras.ino.
Mudras is a gestural sequencer for modular and CV-based instruments. It uses a VL53L0X time-of-flight sensor to track hand position, converts that motion into either quantized pitch CV or smooth linear control voltage, and records/playbacks sequences in sync with an external gate or clock.
- Turn off your rack, and plug the provided cable into the keyed header on the back. Don't fight the keyed header, and ensure the redline is on the side that says "REDLINE". Turn on your rack.
- Feed an external clock or gate into the input labeled Clock.
- Set sequence length with the knob labeled Length.
- Choose a scale or linear mode with the knob on Scale
- Hold the round circular touch button at the bottom of the panel and move your hand over the sensor to record steps.
- Release the touch button and the sequence steps forward on each new rising edge seen on the clock input.
- Hand-position control with a VL53L0X distance sensor
- External clock/gate input for step advancement
- Record and playback modes selected with a button
- Variable loop lengths from 2 to 64 steps
- 7 quantized musical scales plus 1 linear CV mode
- 12-bit DAC CV output on
PA4
Mudras Uses a STM32G431, but it will work and this code is compatible with any STM32 Chip that has a built in DAC
| Pin | Function |
|---|---|
D4 |
Record/play button input (INPUT_PULLUP, active low) |
D5 |
External gate/trigger input, falling-edge interrupt |
PA0 |
Loop length knob |
PA1 |
Scale selection knob |
PA4 |
12-bit DAC CV output |
SDA/SCL |
I2C connection to VL53L0X sensor |
- An external trigger on
D5advances the sequencer. - The interrupt service routine only sets a flag.
- Step advance, record, and playback logic are handled in the main loop.
- Hold the
D4button to record. - Release the
D4button to play back the stored sequence. - Entering record mode from playback resets recording to step 0.
The distance sensor is read continuously:
- In scale modes, hand distance is mapped to a note index.
- In linear mode, hand distance is mapped directly to the full 12-bit DAC range.
The scale knob selects one of 8 modes:
| Mode | Behavior |
|---|---|
| 0 | Major |
| 1 | Dorian |
| 2 | Minor Pentatonic |
| 3 | Harmonic Minor |
| 4 | Diminished |
| 5 | Whole Tone |
| 6 | Chromatic |
| 7 | Linear CV (no quantization) |
The loop length knob selects one of these sequence lengths:
- 2 steps
- 3 steps
- 4 steps
- 8 steps
- 16 steps
- 32 steps
- 64 steps
- Hand distance is mapped to a scale index.
- The scale table converts that index to a note.
- The note is converted to volts using 1V/octave.
- Voltage is converted to a 12-bit DAC value.
- The DAC outputs CV on
PA4.
- Hand distance is mapped directly to
0-4095. - The raw DAC value is recorded or played back.
- The DAC outputs smooth unquantized CV on
PA4.
This sketch depends on:
WireAdafruit_VL53L0XResponsiveAnalogRead
- DAC output uses 12-bit resolution.
- I2C is configured for 400 kHz.
- The sequencer stores up to 64 steps in memory.
- The external gate input is expected to be level-shifted/protected before reaching
D5. - The step counter starts at -1 so that the first incoming gate increments it to step 0 before any playback or recording happens.
- Main firmware:
mudras.ino