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. 

1 ACCEPTED SOLUTION

Accepted Solutions

@TechyAry wrote:

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


Again, the Blue pill will (almost) certainly not have a genuine STM32 - so, if it works on a genuine STM32, definitely suspect the Blue Pill!

There are loads of posts here about the grief people have with these Blue Pills; eg,

https://community.st.com/t5/stm32-mcus-products/configuring-uart-on-stm32f103c8t6-bluepill-kills-connection-to/m-p/668641/highlight/true#M242690

 


@TechyAry wrote:

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)


Probably not - because you need separate connections to pairs of adjacent pins.

But they are standard 0.1" pitch - so can be used with standard soldered prototyping boards.

You can also get prototyping boards to fit on the Arduino connectors.

But this a separate question - please start a new thread in the  STM32 MCUs Boards and hardware tools section for that.

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.

View solution in original post

8 REPLIES 8
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

 


@TechyAry wrote:

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


Again, the Blue pill will (almost) certainly not have a genuine STM32 - so, if it works on a genuine STM32, definitely suspect the Blue Pill!

There are loads of posts here about the grief people have with these Blue Pills; eg,

https://community.st.com/t5/stm32-mcus-products/configuring-uart-on-stm32f103c8t6-bluepill-kills-connection-to/m-p/668641/highlight/true#M242690

 


@TechyAry wrote:

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)


Probably not - because you need separate connections to pairs of adjacent pins.

But they are standard 0.1" pitch - so can be used with standard soldered prototyping boards.

You can also get prototyping boards to fit on the Arduino connectors.

But this a separate question - please start a new thread in the  STM32 MCUs Boards and hardware tools section for that.

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.

@TechyAry wrote:

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


it looks like you have double-ended headers on your board; ie, connections are accessible both above & below the pill board.

So have you tried connecting direct to the "top" end of the header - instead of via the breadboard?

Breadboard contacts are notoriously unreliable.

 

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.

Ended up being using male-to-female jumper wires. Handy. 

Left the blue pill away and got back to the nucleo. IT works fine.

Something of the blue pill we didn't note seemingly is its jumpers. They can be switched based on the need. 

Anyway, I'm much more OK with the nucleo.
Thanks for your help and comments.