Nucleo button
A pushbutton from PC13 to GND is the Nucleo’s USER button: pressing it lights the green LED on D13. The whole build, an STM32 Nucleo-F411RE and 1 more part, 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 $16.10. 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.
// Button: the blue USER button B1 lights the green LED while it is held.
//
// B1 sits between PC13 and GND, and the board has its own 4.7 k pull-up (R30)
// on that pin, so plain INPUT is enough: PC13 reads HIGH released and LOW
// pressed. USER_BTN is STM32duino's name for it.
//
// The buttons drawn on the board do not take clicks in Mokxi, so to press B1
// here wire a pushbutton from PC13 (on the left morpho header) to GND, which
// is exactly what B1 does on the real board.
void setup() {
pinMode(USER_BTN, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
bool pressed = digitalRead(USER_BTN) == LOW;
digitalWrite(LED_BUILTIN, pressed ? HIGH : LOW);
delay(5);
}
Parts list
3 parts, plus the jumper wires. They retail for about $16.10; on Mokxi they're free.
- 1 × STM32 Nucleo-F411RE
- 1 × Half breadboard
- 1 × Pushbutton
How it is wired
2 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.
- STM32 Nucleo-F411RE pin PC13; Pushbutton pin 1a
- Ground: STM32 Nucleo-F411RE pin GND; Pushbutton pin 2a
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.