Blinking of Onboard Led Using STM32-Black Pill
by Prateek Thapar in Circuits > Microcontrollers
71 Views, 1 Favorites, 0 Comments
Blinking of Onboard Led Using STM32-Black Pill
![dasd.jpeg](/proxy/?url=https://content.instructables.com/F6O/1B3O/LUGYNLJR/F6O1B3OLUGYNLJR.jpg&filename=dasd.jpeg)
Welcome to our tutorial on using STM32CubeIDE to control the on-board LED of the STM32 Black Pill microcontroller. We'll guide you through setting up the environment, understanding hardware specifics, writing LED control code, and testing/debugging. By the end, you'll confidently manipulate the LED using STM32CubeIDE. Let's get started!
Supplies
STM32-Black Pill, STMCubeIDE.
Making a New Project File in STM32CubeIDE
![Screenshot (17).png](/proxy/?url=https://content.instructables.com/F72/EZGG/LUGYNKOO/F72EZGGLUGYNKOO.png&filename=Screenshot (17).png)
Open stm IDE>file>new>stm project.
ADD Configurations for Your STM Board
![Screenshot (18).png](/proxy/?url=https://content.instructables.com/FGU/7C7V/LUGYNKRB/FGU7C7VLUGYNKRB.png&filename=Screenshot (18).png)
![Screenshot (19).png](/proxy/?url=https://content.instructables.com/F44/23VQ/LUGYNKRV/F4423VQLUGYNKRV.png&filename=Screenshot (19).png)
Search For Component- STM32F401CEY6TR click on "Next"
Configuring Your Board
![Screenshot (20).png](/proxy/?url=https://content.instructables.com/FG4/8JX9/LUGYNKSB/FG48JX9LUGYNKSB.png&filename=Screenshot (20).png)
Clock Configuration
![Screenshot (21).png](/proxy/?url=https://content.instructables.com/FOY/M94I/LUGYNKTW/FOYM94ILUGYNKTW.png&filename=Screenshot (21).png)
Open Main.c File
![Screenshot (22).png](/proxy/?url=https://content.instructables.com/FN4/YUK5/LUGYNKXZ/FN4YUK5LUGYNKXZ.png&filename=Screenshot (22).png)
Goto While(1) in Main() and Add Your Code
Write this under the while section:
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);
HAL_Delay(500);
Debug
![Screenshot (23).png](/proxy/?url=https://content.instructables.com/FHD/P7D9/LUGYNL30/FHDP7D9LUGYNL30.png&filename=Screenshot (23).png)
Copy Path of .elf File Generated
![Screenshot (24).png](/proxy/?url=https://content.instructables.com/FOO/7TUN/LUGYNL4J/FOO7TUNLUGYNL4J.png&filename=Screenshot (24).png)
Open STMCubeProgrammer and Connect to STM Board Via USB
![Screenshot (25).png](/proxy/?url=https://content.instructables.com/F5S/ZS21/LUGYNL9R/F5SZS21LUGYNL9R.png&filename=Screenshot (25).png)
Click on Open File and Paste the Copied Path
![Screenshot (26).png](/proxy/?url=https://content.instructables.com/FOP/8SRE/LUGYNLAQ/FOP8SRELUGYNLAQ.png&filename=Screenshot (26).png)
Go to Download Options
![Screenshot (27).png](/proxy/?url=https://content.instructables.com/FJ1/YVXN/LUGYNLBQ/FJ1YVXNLUGYNLBQ.png&filename=Screenshot (27).png)
Change Download Options and Click on "Start Automatic Mode"
![Screenshot (28).png](/proxy/?url=https://content.instructables.com/FGG/F6OU/LUGYNLCU/FGGF6OULUGYNLCU.png&filename=Screenshot (28).png)