Built-in project · Seeed XIAO ESP32-C3

XIAO C3 knob

A potentiometer on D0 dims an LED on D10, using the XIAO’s own pin names rather than the chip’s GPIO numbers. The whole build, a Seeed XIAO ESP32-C3 and 3 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Runs in your browser. Free, and no account needed.

XIAO C3 knob · Seeed XIAO ESP32-C3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Seeed XIAO ESP32-C3
// Knob: a potentiometer on D0 sets the brightness of an LED on D10.
//
// D0 is A0, which is GPIO 2 and ADC1 channel 2. The converter is twelve bits,
// 0 to 4095, and at its default 11 dB attenuation full scale is about 3.3 V,
// so the sketch turns the count into millivolts with the supply it knows.
// D3 is labelled A3 on the board too, but it is on ADC2, which Mokxi does not
// model, so use D0, D1 or D2 for anything analogue.

const int KNOB = A0;
const int LED = D10;

unsigned long lastReport = 0;

void setup() {
  Serial.begin(115200);
  pinMode(LED, OUTPUT);
}

void loop() {
  int raw = analogRead(KNOB);
  analogWrite(LED, raw >> 4);

  unsigned long now = millis();
  if (now - lastReport >= 200) {
    lastReport = now;
    long mv = (long)raw * 3300 / 4095;
    Serial.print("D0 ");
    Serial.print(mv);
    Serial.println(" mV");
  }
  delay(10);
}

Parts list

5 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

5 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Seeed XIAO ESP32-C3 pin D0; Potentiometer pin 2
  • Ground: Seeed XIAO ESP32-C3 pin GND; Potentiometer pin 3; LED, green pin C
  • Seeed XIAO ESP32-C3 pin 3V3; Potentiometer pin 1
  • Seeed XIAO ESP32-C3 pin D10; Resistor, 220 Ω pin 1
  • Resistor, 220 Ω pin 2; LED, green pin A

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.