Built-in project · Wemos D1 R32

D1 R32 button

A button on the Wemos D1 R32’s D2 hole, which is GPIO 26, lights an LED on D3, GPIO 25, and the blue LED on GPIO 2. The whole build, a Wemos D1 R32 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 $13.25. On Mokxi they're free.

D1 R32 button · Wemos D1 R32live0.000 s 0.00x
Hold the button
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 · Wemos D1 R32
// Button: the Uno's numbers are not the pins' numbers on a D1 R32.
//
// The hole printed D2 is GPIO 26 and the hole printed D3 is GPIO 25, so the
// sketch says 26 and 25. digitalWrite(2, ...) would be the blue LED on GPIO 2,
// which is the A0 hole, not D2.

const int kButton = 26; // D2, to GND
const int kLed = 25;    // D3, an LED and a resistor to GND

void setup()
{
    pinMode(kButton, INPUT_PULLUP);
    pinMode(kLed, OUTPUT);
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
    bool pressed = digitalRead(kButton) == LOW;
    digitalWrite(kLed, pressed ? HIGH : LOW);
    digitalWrite(LED_BUILTIN, pressed ? HIGH : LOW);
    delay(10);
}

Parts list

5 parts, plus the jumper wires. They retail for about $13.25; on Mokxi they're free.

How it is wired

4 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.

  • Wemos D1 R32 pin IO25; Resistor, 220 Ω pin 1
  • Wemos D1 R32 pin IO26; Pushbutton pin 1a
  • Ground: Wemos D1 R32 pin GND; Pushbutton pin 2b; LED, green pin C
  • 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.