XIAO C6 knob
The XIAO ESP32-C3’s knob circuit, pad for pad, on the ESP32-C6: D0 is still A0, though the GPIO under it has changed. The whole build, a Seeed XIAO ESP32-C6 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.
Teaching? Assign it to your class in one click.
Beginner Runs in your browser. Free, and no account needed.
The parts retail for about $10.85. On Mokxi they're free.
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// Knob: a potentiometer on D0 sets the brightness of an LED on D10.
//
// D0 is A0, which is GPIO 0 and ADC1 channel 0. 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.
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. They retail for about $10.85; on Mokxi they're free.
- 1 × Seeed XIAO ESP32-C6
- 1 × Full-size breadboard
- 1 × Potentiometer
- 1 × Resistor, 220 Ω
- 1 × LED, green
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-C6 pin D0; Potentiometer pin 2
- Ground: Seeed XIAO ESP32-C6 pin GND; Potentiometer pin 3; LED, green pin C
- Seeed XIAO ESP32-C6 pin 3V3; Potentiometer pin 1
- Seeed XIAO ESP32-C6 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.