To Get Start With STM32 Black Pill and STM Cube IDE to Implement a Sequence Where Three LEDs Blink in Various Combinations. These Combinations Will In

by krishgupta2210 in Circuits > Microcontrollers

14 Views, 0 Favorites, 0 Comments

To Get Start With STM32 Black Pill and STM Cube IDE to Implement a Sequence Where Three LEDs Blink in Various Combinations. These Combinations Will In

FFRY953LUSE67CG.jpg

Welcome to our instructable blog, where we set out on an enlightening excursion into the domain of microcontroller programming utilizing the strong STM32 Dark Pill. In this instructional exercise, we'll dive into the entrancing universe of implanted frameworks as we figure out how to squint one, yet three LEDs in charming examples.


Saddling the capacities of the STM32 Dark Pill, we'll investigate the complexities of controlling numerous LEDs and making dynamic lighting successions. Toward the finish of this aide, you'll have acquired significant experiences into programming microcontrollers, leveled up your abilities in working with GPIO sticks, and excelled at making entrancing Drove designs.


Thus, whether you're a carefully prepared devotee hoping to extend your insight or an inquisitive novice anxious to jump into the universe of implanted gadgets, go along with us as we enlighten the dimness with the splendor of three LEDs and open the capability of the STM32 Dark Pill. We should get everything rolling on this zapping experience!

Supplies

  1. STM32 Black Pill
  2. Bread Board
  3. M-M jumper connector cables
  4. LED (3 nos.)
  5. USB TYPE-C cable


Step 1: Follow Steps 1 to 6 From My Other Blog


https://www.instructables.com/To-Get-Start-With-STM32-Black-Pill-and-STM-Cube-ID-2/


Step 2: Enter the Following Code in While(1) Block

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);




This code controls three LEDs connected to GPIO pins on an STM32 microcontroller. Let's break it down step by step:


1. `HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);`: This line turns off the LED connected to pin 13 of GPIO port C.


2. `HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);`: This line turns off the LED connected to pin 14 of GPIO port C.


3. `HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);`: This line turns off the LED connected to pin 15 of GPIO port C.


4. `HAL_Delay(400);`: This line adds a delay of 400 milliseconds, which means the program will wait for 400 milliseconds before executing the next line of code.


5. The next series of lines follows a similar pattern, but they turn on one LED at a time while keeping the others off. For example:

  - `HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);` turns off the LED on pin 13.

  - `HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);` turns on the LED on pin 14.

  - `HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);` keeps the LED on pin 15 off.

  - Then there's another delay of 400 milliseconds.


6. This sequence repeats for each LED, cycling through different combinations of LEDs being on and off.


In essence, this code creates a pattern where the LEDs connected to pins 13, 14, and 15 of GPIO port C blink in a specific sequence, with each LED turning on and off at different times. The delay between each change in LED state determines the speed of the blinking pattern.

Step 3: Follow Step 7 to 12 From My Other Blog in Order to Upload the Code to the Controller

https://www.instructables.com/To-Get-Start-With-STM32-Black-Pill-and-STM-Cube-ID-2/