LED Counter Using STM32 Black Pill Using STM32CubeIDE
by Anjandeep Singh in Circuits > Microcontrollers
5 Views, 0 Favorites, 0 Comments
LED Counter Using STM32 Black Pill Using STM32CubeIDE
![IMG_3061.JPG](/proxy/?url=https://content.instructables.com/F0A/ELI9/LUWOHETQ/F0AELI9LUWOHETQ.jpg&filename=IMG_3061.JPG)
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:
- STM32 Black Pill
- USB-C Cable
- Laptop or desktop
- 3 LEDs
- 4 Jumper Wires
- Breadboard
Software:
- STM32CubeIDE
- STM32CubeProgrammer
Create Project on STM32CubeIDE
- Create a project using STM32CubeIDE and choose the appropriate board type.
- Select GPIO output pins. I have chosen A3, A4 and A5.
- Adjust the clock according to your needs.
- Press Alt + K to generate code.
Check other instructables on my profile for detailed steps.
Programming
![stm32cubeide_bijGgKuDuQ.png](/proxy/?url=https://content.instructables.com/FXR/16GI/LUWOHJUG/FXR16GILUWOHJUG.png&filename=stm32cubeide_bijGgKuDuQ.png)
- Open your project in Project Explorer and follow this path; Core > Src > main.c.
- In main.c, inside int main() code block go to while(1) to write the code to turn on/ off the LEDs in 8 different combinations.
- Add delay so you are able to see the output.
- Save the file and press on debug.
Copying Path of .elf File From File Explorer
- Right click on the STMProject or use Alt + Shift + W shortcut and press "System Explorer"
- Open the project folder then "Debug" and copy path of .elf file.
Upload Code to STM Using STM32CubeProgrammer
![javaw_xBd5Pxp5LM.png](/proxy/?url=https://content.instructables.com/FU5/T6O6/LUWOHL6W/FU5T6O6LUWOHL6W.png&filename=javaw_xBd5Pxp5LM.png)
![javaw_m28EzzBT7e.png](/proxy/?url=https://content.instructables.com/FQM/E2X7/LUWOHLDN/FQME2X7LUWOHLDN.png&filename=javaw_m28EzzBT7e.png)
- Once the file is saved in STM32CubeIDE connect the STM32 board after bootloader.
Check other instructables for more detailed steps.
- Press on "Open file" and select the .elf from the path copied earlier.
- Press on "Download" on the right.
- Go to the "Erasing & programming" from the menu in the left.
- Paste the File path copied earlier.
- Check the "Full chip erase" and "Download file" and press on "Start automatic mode".
Result
- Once the chip is erased, the code will be ready to upload on the chip.
- To upload, disconnect and reconnect the USB-C cable and your LEDs will start blinking.
Thank you!