Introduction: LED PATTERN Making Using STM32F401CE

Today We are going to create a 3-led blinking pattern using stm32f401ce with HAL programming in STM32cubeIDE.


Supplies

Material Required:

  1. STM32F401CE
  2. USB-C-TYPE CABLE
  3. LED
  4. BREADBOARD
  5. M-M JUMPER

Step 1: Create New File

To open new file :

File>>new>>STM32 Project.

After opening file, Choose your Board ,we are using STM32F401CE Board.

NEXT>> name your file.

Step 2: PIN Configuration & Clock Configuration

Goto to System core>> GPIO>> Choose PC13, PC14, PC15 to GPIO_OUTPUT.

For Clock Configration:

System Core >> RCC >> HCS>> Crystal/ceramic Clock.

And refer To provided image for setting clock.

Step 3: CODING

After configuring STM32 save yor file by CTRL+S,

and coding file will open. Write code as given in text file or write code as you want to make pattern of LED's.

Code explanation:

it’s controlling the state of three pins (13, 14, 15) on port C. The HAL_GPIO_WritePin function is used to set the state of a specific pin to either HIGH (1) or LOW (0). The HAL_Delay function is used to introduce a delay, in this case, 400 milliseconds.

The code is cycling through different combinations of states for the three pins, with a delay after each change. This could be used, for example, to control LEDs connected to these pins, making them blink in a specific pattern. The pattern here is a binary count from 0 (all pins LOW) to 7 (all pins HIGH), with each step lasting 400 milliseconds.

Step 4: DEBUG

After writing code Debug by clicking Hammer icon , Deguged file is created with Your project name and with .elf extension

Step 5: Uploding Code

Open STM32cubeProgrammer and connect your STM board (For detail refer to previous Blogs) ,

Open erasing and Programming option and enter your saved file path or browse it.

select option as shown in picture, Now click start automatic mode.


YOUR LED BLINKING PATTERN IS CREATED. :)

Step 6: Output Photo and Video