cancel
Showing results for 
Search instead for 
Did you mean: 

Blue pill blink external LED

TechyAry
Associate III

I used the settings and code below for a simple project: Blink an external DIP LED using the blue pill:
In Pinout & Configuration:
- PA5 => GPIO_Output
- user label: LED


The wire connections (like screenshot below):
PA5 pin => Resistor => Long leg (anode) of LED
Short leg (cathode) => GND on Blue Pill

 

photo_2025-08-09_11-19-55.jpg

And finally code: 

while (1)
  {
	  HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
	  HAL_Delay(500);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

But the LED doesn't turn on!
What could be the reason?

 

The .ioc file is also attached. 

4 REPLIES 4
Andrew Neil
Super User

Note that the Blue Pill is not an ST product, and likely does not have a genuine STM32.

What testing/debugging/investigation have you done to find what's wrong?

If you simply take that flying lead and connect it to +3V, does the LED light?

 

What's going on here:

AndrewNeil_0-1754727669633.png

You seem to have both the LED and the resistor pushed into the same hole on the breadboard?!

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

> What testing/debugging/investigation have you done to find what's wrong?

Using 3.3 => Anode => Cathode => resister => GND the LED turns on

Also, when using PC13 for the same purpose, the onboard LED blinks correctly. 

Not sure what else I should do.

 

> If you simply take that flying lead and connect it to +3V, does the LED light?

You mean anode to 3.3 and cathode to GND without a resister?

 

>You seem to have both the LED and the resistor pushed into the same hole on the breadboard?!

yeah, because the resister's leads are very thin and I doubted they might not fit well into the holes. 


@TechyAry wrote:

Also, when using PC13 for the same purpose, the onboard LED blinks correctly. 


So the issue is with the PA5 pin, then.

Have you checked that it's making good contact with the breadboard?

Have you checked the board schematic to see if there's anything else connected to that pin?

Have you tried other PAxx pins?

Have you tried this on a real STM32?

Note that, for a real STM32, it's not recommended to drive LEDs from PC13, PC14 or PC15:

AndrewNeil_0-1754730916041.png

https://www.st.com/resource/en/datasheet/stm32f103c8.pdf#page=33

 


@TechyAry wrote:

> If you simply take that flying lead and connect it to +3V, does the LED light?

You mean anode to 3.3 and cathode to GND without a resister?


No! Never connect an LED direct to a power supply without a resistor!

I meant to just take the top end of the red wire, and connect it to +3V:

AndrewNeil_1-1754731254818.png

 


@TechyAry wrote:

yeah, because the resister's leads are very thin and I doubted they might not fit well into the holes. 


and yet you have the other end in a hole on its own?!

Seriously, putting 2 wires into 1 hole is more likely to give an unreliable connection.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Connecting the top end of the red wire to +3V will turn on the LED.

I also tested PB8 instead of PA5, yet no success.

The mcu seems to be normally connecting to the bread board. 

Testing the same project with Nucelo-64 (STM32F411RE) works properly.

1- Is the issue then with the blue pill itself? (Or maybe its debugger or utility)

2- Is there any specific type of breadboard I can purchase for my Nucleo board? (So that I can access all pins on the edges as well as the ones on the green lines below)

u00-01-9780081029695.jpg