Introduction: Activating the On-Board LED of the STM32 Black Pill: a Simple Guide

Welcome to our step-by-step guide on using STM32CubeIDE to control the built-in LED of the STM32 Black Pill microcontroller. We've designed this tutorial to be easy to follow, even if you're new to embedded development. You'll learn how to set up your environment, get to know the Black Pill's hardware, and write code to control the LED. This basic exercise is essential for getting started with microcontroller programming. Let's dive in and explore together!

Supplies

Before we get started with embedded programming, make sure you have the following:


1. A laptop or desktop computer with STM32CubeIDE and STM32CubeProgrammer installed.


2. An STM32 Black Pill development board.


3. A USB cable that works with your board for connection and programming.


Having these ready will ensure a smooth and hassle-free programming experience. Let's dive in!

Step 1: Making a New Project File in STM32CubeIDE

OPEN File>New>STM32 Project

Step 2: ADD Configurations

Find and select your STMboard

In our case we will be using STM32F401CCU6

Step 3: Configuring Your Board and Clocks

Once Done With These Steps Press CTRL+S to generate "main.c" File

Step 4: Entering the Code

Locate and Open the main.c file (located in Core>>SRC>>main.c) & and add the above code in While(1) Loop

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);

HAL_Delay(500);

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);

HAL_Delay(500);

Here we have used Pin 13 beacuse it has the internal LED Connected to it

Step 5: Debug

Click on Debug


Step 6: Locate File Locate in System

Right click on Project and click on show in system explorer and copy the path

Step 7: Open STMCubeProgrammer

Connect the STM Board using USB

Step 8: Modify the Download Settings and Select "Begin Automatic Mode."

Step 9: Done, LED Is Now Blinking