LED PATTERN Making Using STM32F401CE

by devraj4520 in Circuits > Electronics

94 Views, 0 Favorites, 0 Comments

LED PATTERN Making Using STM32F401CE

WhatsApp Image 2024-04-10 at 17.42.00_f74916fc.jpg

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


Supplies

Bread board.jpeg
STM32F401CE.jpeg
usb-c-type-cable.jpg
Screenshot 2024-04-09 180806.png
MM jumper.jpeg

Material Required:

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

Create New File

Screenshot 2024-03-17 101441.png
Screenshot 2024-03-17 101613.png

To open new file :

File>>new>>STM32 Project.

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

NEXT>> name your file.

PIN Configuration & Clock Configuration

Screenshot 2024-04-10 180003.png
Screenshot 2024-04-09 182319.png

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.

CODING

Screenshot 2024-04-10 180956.png

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.

DEBUG

Screenshot 2024-04-10 182047.png

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

Uploding Code

Screenshot 2024-04-10 183032.png

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. :)

Output Photo and Video

F1H9FULLUSE5XVZ.jpg