Built-in project · Raspberry Pi Pico
Pico arcade button
A 30 mm arcade button on GP15 lights a lamp on GP14 and the Pico's own LED while it is held. The whole build, a Raspberry Pi Pico 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.
StarterRuns in your browser. Free, and no account needed.
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 · Raspberry Pi Pico
// Button: read a pin, drive a pin.
//
// Wire a pushbutton from GP15 to any GND pin. INPUT_PULLUP switches on the
// pad's 55 k pull-up, so the pin reads HIGH when the button is up and LOW when
// it is pressed: no external resistor, and no floating input.
//
// GP25, the on-board LED, is inside the module, so the sketch lights GP14 as
// well for an LED on the breadboard.
const int BUTTON = 15;
const int LED = 14;
void setup() {
pinMode(BUTTON, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED, OUTPUT);
}
void loop() {
int pressed = digitalRead(BUTTON) == LOW ? HIGH : LOW;
digitalWrite(LED_BUILTIN, pressed);
digitalWrite(LED, pressed);
}
Parts list
5 parts, plus the jumper wires. Every one is in the editor's parts bin.
- 1 × Raspberry Pi Pico
- 1 × Full-size breadboard
- 1 × Resistor, 220 Ω
- 1 × LED, green
- 1 × Arcade button
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.
- Ground: Raspberry Pi Pico pin GND; LED, green pin C; Arcade button pin 1
- Raspberry Pi Pico pin GP14; Resistor, 220 Ω pin 1
- Raspberry Pi Pico pin GP15; Arcade button pin 2
- 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.