PoleMixing_RP2040_12nov2026 — Xiao Rp2040 simulation

An interactive Xiao Rp2040 circuit simulation you can run free in your browser on Velxio, by bwei.

Components

Sketch code

//#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <hardware/pwm.h>
#include <hardware/clocks.h>
#define SCREEN_WIDTH  128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
#define OLED_ADDRESS  0x3C

// Hardware Pin Definitions for RP2040
#define PIN_CUTOFF    26 // ADC0 (Potentiometer 1)
#define PIN_RESONANCE 27 // ADC1 (Potentiometer 2)
#define PIN_ENCODER_A 2  // Quadrature Encoder A
#define PIN_ENCODER_B 3  // Quadrature Encoder B
#define ENCODER_BTN_PIN 4   // D9 - Encoder Click Switch

// Pin definition for PWM output
const uint PWM_PIN = 6; // Pin D6 on XIAO RP2040
// Sine wave and PWM configuration variables
float targetFrequency = 1.0; // Current frequency (0.1 Hz to 100 Hz)
uint slice_num;
uint channel;
// High PWM frequency for inaudible operation (e.g., ~25 kHz)
// RP2040 clock is typically 125 MHz. 
// Wrap value = 125,000,000 / (PWM_FREQ * Prescaler)
const uint32_t kach = 25000; // 25 kHz carrier frequency
uint16_t wrapValue = 5000;  // 125,000,000 / (25000 * 1) = 5000 steps of resolution


Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


// Menu Selection Classification

        uint8_t current_Menu_Selected = 0; //0=PoleMix1 ; 1=PoleMix2
        const uint8_t nbTOTAL_Menu = 3;
//GESTION MODE de FILTRE
        // Filter Shape Classification
        enum FilterShape {
            SHAPE_LOWPASS,
            SHAPE_HIGHPASS,
            SHAPE_BANDPASS,
            SHAPE_NOTCH,
            SHAPE_ALLPASS,
            SHAPE_HP_LP,
            SHAPE_ResNOTCH,
            SHAPE_NOTCHRes,
            SHAPE_LP_NOTCH
        };

        struct FilterMode {
            const char* name;
            FilterShape shape;
            uint8_t pole_beforeCutoff; // 1 to 4 poles (determines slope steepness)
            uint8_t pole_afterCutoff;
        };

        // Oberheim Matrix-12 / Xpander Inspired Response Types
        const FilterMode FILTER_MODES[] = {
            {"LP1",   SHAPE_LOWPASS,  1,1}, //1-Pole Lowpass
            {"LP2",   SHAPE_LOWPASS,  2,2},//2-Pole Lowpass
            {"LP3",   SHAPE_LOWPASS,  3,3},//3-Pole Lowpass
            {"LP4",   SHAPE_LOWPASS,  4,4},
            {"HP1",  SHAPE_HIGHPASS, 1,1},//1-Pole Highpass
            {"HP1+LP2",  SHAPE_HP_LP, 1,2},
            {"HP1+LP3",  SHAPE_HP_LP, 1,3},
            {"HP2+LP1",  SHAPE_HP_LP, 2,1},
            {"HP3+LP1",  SHAPE_HP_LP, 3,1},
            {"HP2",  SHAPE_HIGHPASS, 2,2},
            {"HP3",  SHAPE_HIGHPASS, 3,3},
            {"HP4",  SHAPE_HIGHPASS, 4,4},
            {"BP2",  SHAPE_BANDPASS, 2,2},//2-Pole Bandpass
            {"BP4",  SHAPE_BANDPASS, 4,4},
            {"NO2",     SHAPE_NOTCH,    2,2},//2-Pole Notch
            {"NO4",     SHAPE_NOTCH,    4,4},
            {"Res+N",     SHAPE_ResNOTCH,    4,4},
            {"N+Res",     SHAPE_NOTCHRes,    4,4},
            {"LP1+NOA",     SHAPE_LP_NOTCH,    1,4},// slopeLP, slopeNotch
            {"

More projects by bwei