STM32F411 Black Pill pinout: every pin, and the three buttons
Beginner
Or see every lesson.
- 505parts on the bench
- 45boards running now
- 1.00xreal time, on every board
The Black Pill is WeAct’s MiniF4 board: an STM32F411CEU6, a Cortex-M4, on a board with twenty pins down each side, a USB-C socket and three buttons, BOOT0, NRST and KEY. Its pins are named by port and number, so the hole printed A5 is PA5 in code. This page lists every pin with its silkscreen name, what it can do and what to watch for, then power and the 5 V tolerant pins, the LED that lights on LOW, the buttons and the pins the USB and the debug port hold.
The circuit above is a Black Pill in Mokxi running a six-LED chaser on PA1 to PA6. Mokxi runs the chip at 84 MHz, and the table is read from the same board model the simulator runs. Where Mokxi does less than the chip, the row says so.
Every pin, by port and silkscreen
With the USB-C socket at the top, the left row reads B12, B13, B14, B15, A8 to A12, A15, B3 to B9, 5V, G and 3V3, and the right row reads 5V, G, 3V3, B10, B2, B1, B0, A7 down to A0, R, C15, C14, C13 and VB, at the far end from the socket. A four-pin SWD header across that far end carries 3V3, PA13, PA14 and GND. Mokxi draws the board the same way, and the table follows it: the left row down, the right row down, then the SWD pins. Each power pin is listed once.
The silkscreen leaves off the P, and in code the pin is written in full: digitalWrite(PC13, LOW). Careful with the analog names. The hole printed A9 is PA9, the serial TX pin, while A9 in a sketch is PB1, the tenth analog input.
| Pin | Silkscreen | What it can do | Watch out for |
|---|---|---|---|
| PB12 | B12 | Digital. SPI2 NSS on the chip (not modeled). | - |
| PB13 | B13 | Digital. SPI2 SCK on the chip (not modeled). | - |
| PB14 | B14 | Digital. SPI2 MISO on the chip (not modeled). | - |
| PB15 | B15 | Digital. SPI2 MOSI on the chip (not modeled). | - |
| PA8 | A8 | Digital. | - |
| PA9 | A9 | TX: Serial, on USART1. | The ROM bootloader answers on it too. |
| PA10 | A10 | RX: Serial, on USART1. | The ROM bootloader listens on it too. |
| PA11 | A11 | Digital. USB D- on a real board. | Drive it and the USB-C socket stops working. |
| PA12 | A12 | Digital. USB D+ on a real board. | Drive it and the USB-C socket stops working. |
| PA15 | A15 | Digital. JTAG’s JTDI out of reset. | pinMode takes it from the debug port. |
| PB3 | B3 | Digital. JTAG’s JTDO out of reset. | pinMode takes it from the debug port. |
| PB4 | B4 | Digital. JTAG’s NJTRST out of reset. | pinMode takes it from the debug port. |
| PB5 | B5 | Digital. | Not 5 V tolerant on the F411. |
| PB6 | B6 | PWM on TIM4 channel 1. I2C SCL (default). | - |
| PB7 | B7 | PWM on TIM4 channel 2. I2C SDA (default). | - |
| PB8 | B8 | PWM on TIM4 channel 3. I2C SCL with Wire.setSCL(PB8). | - |
| PB9 | B9 | PWM on TIM4 channel 4. I2C SDA with Wire.setSDA(PB9). | - |
| 5V | 5V | USB 5 V with a cable in; put 5 V here to run the board without one. | Not a GPIO. |
| GND | G | Ground. | - |
| 3V3 | 3V3 | The regulator’s 3.3 V output. | Not a GPIO. |
| PB10 | B10 | Digital. I2C2 SCL on the chip (not modeled). | - |
| PB2 | B2 | Digital. BOOT1 on the chip. | Read at reset only when BOOT0 is high. |
| PB1 | B1 | Analog in, ADC channel 9 (A9). PWM on TIM3 channel 4. | - |
| PB0 | B0 | Analog in, ADC channel 8 (A8). PWM on TIM3 channel 3. | - |
| PA7 | A7 | Analog in, ADC channel 7 (A7). PWM on TIM3 channel 2. SPI MOSI (default). | - |
| PA6 | A6 | Analog in, ADC channel 6 (A6). PWM on TIM3 channel 1. SPI MISO (default). | - |
| PA5 | A5 | Analog in, ADC channel 5 (A5). SPI SCK (default). | - |
| PA4 | A4 | Analog in, ADC channel 4 (A4). SPI SS (default). | - |
| PA3 | A3 | Analog in, ADC channel 3 (A3). PWM on TIM5 channel 4. USART2 RX on the chip. | - |
| PA2 | A2 | Analog in, ADC channel 2 (A2). PWM on TIM5 channel 3. USART2 TX on the chip. | - |
| PA1 | A1 | Analog in, ADC channel 1 (A1). PWM on TIM5 channel 2. | - |
| PA0 | A0 | Analog in, ADC channel 0 (A0). PWM on TIM5 channel 1. The KEY button. | KEY grounds it: use INPUT_PULLUP. Not 5 V tolerant. |
| NRST | R | Reset: low restarts the chip, as the NRST button does. | Not a GPIO. |
| PC15 | C15 | Digital. OSC32_OUT: the board’s 32.768 kHz crystal. | Leave it to the crystal. |
| PC14 | C14 | Digital. OSC32_IN: the board’s 32.768 kHz crystal. | Leave it to the crystal. |
| PC13 | C13 | Digital. The blue LED, lit when LOW. LED_BUILTIN. | Sinks 3 mA at most, shared with PC14 and PC15. |
| VBAT | VB | Backup supply for the clock and backup registers, from a coin cell. | Not a GPIO. Mokxi ignores it. |
| PA13 | A13 | SWDIO: the debug port, where an ST-Link connects. | Held by SWD out of reset; drive it and the ST-Link loses the chip. |
| PA14 | A14 | SWCLK: the debug port’s clock. | Held by SWD out of reset; drive it and the ST-Link loses the chip. |
Power, and which pins take 5 V
5V is the USB rail with a cable in, and the regulator’s input without one. 3V3 is the regulator’s output for the chip and a sensor or two, and the grounds are one ground. VBAT keeps the real-time clock running from a coin cell; Mokxi ignores it. In Mokxi 3V3 and 5V are ideal rails that cannot sag.
The F411 runs at 3.3 V, but most of its pins are 5 V tolerant as digital inputs. WeAct’s pinout drawing marks the exceptions: PA0 and PB5 are 3.3 V only on the F411. A tolerant pin takes 5 V only while it is a digital pin, never while it is an analog input, and its own output still goes no higher than 3.3 V. Mokxi does not model the difference, so check this before you wire a 5 V signal on a desk.
The LED on PC13, by name
The blue LED is wired from 3.3 V through a resistor to PC13, so it lights when PC13 is driven LOW, and LED_BUILTIN is PC13. PC13 to PC15 can sink only 3 mA between them, enough for that LED and no more. The sketch below drives PC13 low and names the bus pins; in Mokxi it printed "LED_BUILTIN is PC13", "SDA is PB7, SCL is PB6" and "SPI is PA5, PA6, PA7, PA4", and the board’s LED on PC13 lit with the pin LOW.
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // LOW lights the LED on PC13
if (LED_BUILTIN == PC13) Serial.println("LED_BUILTIN is PC13");
if (SDA == PB7 && SCL == PB6) Serial.println("SDA is PB7, SCL is PB6");
if (SCK == PA5 && MISO == PA6 && MOSI == PA7 && SS == PA4) {
Serial.println("SPI is PA5, PA6, PA7, PA4");
}
}
void loop() {
}Open this sketch in the editorThe code alone: the editor places the board and the parts it can read from the sketch.
KEY, NRST and BOOT0
KEY grounds PA0 while it is held and has no resistor of its own, so read it with INPUT_PULLUP: LOW means pressed. NRST is the reset button. BOOT0 is not a header pin, only a button: held while the board resets, it starts ST’s bootloader in the chip’s ROM, which takes a new program over the USB-C socket with a DFU tool or over USART1 on PA9 and PA10. Let go and reset again to run your program.
Mokxi models KEY, which the built-in Button example reads, and the reset. It does not model BOOT0 or the bootloader: the model boots from flash, as with BOOT0 low, and a program is loaded by pressing Run.
Pins the USB and the debug port hold
PA11 and PA12 are the USB socket’s D- and D+. Leave them alone if you want USB, which Mokxi does not model, so here they are plain pins. PA13 and PA14 are SWD, and they and the JTAG pins PA15, PB3 and PB4 come out of reset held by the debug port; on the F411, pinMode on one of them takes it back. Mokxi starts them that way too, from the chip’s own reset values.
Analog, PWM, I2C, SPI and Serial
ADC1 reads ten pins: PA0 to PA7, PB0 and PB1, which are A0 to A9. analogRead gives ten bits by default, 0 to 1023 over 0 to 3.3 V, and analogReadResolution(12) gives the full twelve. analogWrite drives PWM at 1 kHz on twelve pins: PA0 to PA3 on TIM5, PA6, PA7, PB0 and PB1 on TIM3, and PB6 to PB9 on TIM4.
Wire.begin() puts I2C on PB7 for SDA and PB6 for SCL, and Wire.setSDA(PB9) and Wire.setSCL(PB8) move it. SPI is PA5, PA6, PA7 and PA4 for SCK, MISO, MOSI and SS. Mokxi runs both buses in software on those pins, because the chip’s I2C and SPI blocks are not modeled. Serial is USART1 on PA9 and PA10.
Which pin should I use for what?
An analog sensor: PA1 to PA7, PB0 or PB1, leaving PA0 to KEY. An LED to dim: PA1 to PA3, PA6, PA7, PB0, PB1 or PB6 to PB9. A button: any free pin with INPUT_PULLUP, PB12 to PB15 first. An I2C module: PB7 and PB6. An SPI module: PA5 to PA7 with PA4 as chip select. A 5 V signal: a tolerant digital pin such as PB12, never PA0, PB5 or an analog input.
Open this circuit in the editor. Black Pill: a six-LED chaser, wired as it runs at the top of this page. Change a part or a value and run it again.
Open the circuitQuestions
Which STM32F411 Black Pill pins are 5 V tolerant?
Most of them, as digital inputs. WeAct marks PA0 and PB5 as 3.3 V only on the F411, and no pin takes 5 V in analog mode.
Why is the Black Pill LED on when PC13 is LOW?
It is wired from 3.3 V to PC13, so the pin sinks its current. `digitalWrite(PC13, LOW)` lights it and HIGH puts it out.
What are the Black Pill I2C pins?
PB7 for SDA and PB6 for SCL with `Wire.begin()`, or PB9 and PB8 with `Wire.setSDA` and `Wire.setSCL` first.
How do I put a Black Pill into DFU mode?
Hold BOOT0, press and release NRST, then let go of BOOT0. The chip’s ROM bootloader then takes a program over the USB-C socket.
Which pins are analog on the Black Pill?
PA0 to PA7, PB0 and PB1, ADC channels 0 to 9, written `A0` to `A9` or by their port names.
Is the Black Pill pinout the same as the Blue Pill?
No. Both use port names, but the F411 has PA11 and PA12 for USB, a KEY button on PA0, no BOOT1 jumper and different 5 V tolerant pins.
Keep going
Where the facts on this page come from
Build this for real
Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.