Built-in project · ESP32 DevKit V1

ESP32 knob

A pot on GPIO 32 dimming an LED, with the raw reading printed: at 11 dB the converter’s full scale is 3.9 V, so a 3.3 V rail never reaches 4095. The whole build, an ESP32 DevKit 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.

ESP32 knob · ESP32 DevKit V1live0.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 · ESP32 DevKit V1
// Knob: a potentiometer on GPIO32 sets how brightly the LED on GPIO4 burns.
//
// GPIO32 is ADC1 channel 4. At the default 11 dB attenuation the converter's
// full scale is about 3.9 V, so a pot across a 3.3 V rail reads about 0 to
// 3466 rather than 0 to 4095. The sketch prints what it read so the number is
// not a mystery.

const int kKnob = 32;
const int kLed = 4;

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

void loop()
{
    int raw = analogRead(kKnob);
    int duty = map(raw, 0, 4095, 0, 255);

    analogWrite(kLed, duty);
    Serial.print("knob ");
    Serial.print(raw);
    Serial.print(" -> duty ");
    Serial.println(duty);
    delay(200);
}

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.

  • ESP32 DevKit V1 pin D32; Potentiometer pin 2
  • Ground: ESP32 DevKit V1 pin GND; Potentiometer pin 1; LED, red pin C
  • ESP32 DevKit V1 pin D4; Resistor, 220 Ω pin 1
  • ESP32 DevKit V1 pin 3V3; Potentiometer pin 3
  • Resistor, 220 Ω pin 2; LED, red 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.