Skip to main content
August 9, 2025
Solved

Blue pill blink external LED

  • August 9, 2025
  • 1 reply
  • 683 views

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. 

    This topic has been closed for replies.
    Best answer by Andrew Neil

    @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.

    1 reply

    Super User
    August 9, 2025

    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?!

    August 9, 2025

    > 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. 

    Super User
    August 9, 2025

    @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.