LED Counter Using STM32 Black Pill Using STM32CubeIDE

by Tejvinder Singh in Circuits > Microcontrollers

139 Views, 0 Favorites, 0 Comments

LED Counter Using STM32 Black Pill Using STM32CubeIDE

Screenshot 2024-04-14 214929.png

Introduction: LED Counter Using STM32 Black Pill Using STM32CubeIDE

This is a tutorial blog on how to blink 3 LEDs in 8 different combinations. Since 3 in decimal equates to 8 bits in binary I would make it like a counter.

Supplies

Hardware:

1) STM32 Black Pill

2) USB-C Cable Laptop or desktop

3) 3 LEDs

4) 4 Jumper Wires

5) Breadboard

Software:

1) STM32CubeIDE

2) STM32CubeProgrammer

: Create Project on STM32CubeIDE

1) Create a project using STM32CubeIDE and choose the appropriate board type.

2) Select GPIO output pins. I have chosen A3, A4 and A5.

3) Adjust the clock according to your needs.

4) Press Alt + K to generate code.

Check other instructables on my profile for detailed steps.

Programming

Screenshot 2024-04-14 214349.png

1) Open your project in Project Explorer and follow this path; Core > Src > main.c.

2) In main.c, inside int main() code block go to while(1) to write the code to turn on/ off the LEDsin 8 different combinations.

3) Add delay so you are able to see the output.

4) Save the file and press on debug.

Copying Path of .elf File From File Explorer

1) Right click on the STMProject or use Alt + Shift + W shortcut and press "System Explorer"

2) Open the project folder then "Debug" and copy path of .elf file.

Upload Code to STM Using STM32CubeProgrammer

Screenshot 2024-04-14 214815.png
Screenshot 2024-04-14 214840.png

Once the file is saved in STM32CubeIDE connect the STM32 board after bootloader.

Check other instructables for more detailed steps.

1) Press on "Open file" and select the .elf from the path copied earlier.

2) Press on "Download" on the right.

3) Go to the "Erasing & programming" from the menu in the left.

4) Paste the File path copied earlier.

5) Check the "Full chip erase" and "Download file" and press on "Start automatic mode".

Result

1) Once the chip is erased, the code will be ready to upload on the chip.

2) To upload, disconnect and reconnect the USB-C cable and your LEDs will start blinking.

Thank you!