BLINKIG

by jainandan in Circuits > Electronics

61 Views, 1 Favorites, 0 Comments

BLINKIG

Screenshot 2024-05-06 213320.png

The STM32 Black Pill, paired with the STM32CubeIDE, offers an excellent platform for learning embedded systems development. In this tutorial, we'll explore how to implement a sequence where three LEDs blink in various combinations. These combinations will include patterns such as 100, 010, 001, 110, and others, totaling nine distinct combinations. We'll achieve this using HAL (Hardware Abstraction Layer) programming, which simplifies low-level hardware access and configuration on STM32 microcontrollers. By following this tutorial, you'll gain hands-on experience in configuring GPIO pins, controlling LEDs, and creating custom sequences, laying a solid foundation for more complex embedded systems projects. Let's dive in and start blinking those LEDs in exciting patterns!

Supplies

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


Making a New Project File in STM32CubeIDE

GOTO---->> File>New>STM32 Project

ADD Configurations to STM 32Board

Screenshot 2024-05-06 212128.png

Configuring Your Board

Screenshot 2024-05-06 212513.png

Configure Your Clock

Screenshot 2024-05-06 212626.png

Open Main.c File

Screenshot 2024-05-06 212717.png

Goto While(1) in Main() and Add Your Code

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);

Debug

Screenshot 2024-05-06 212855.png

Copy Path of .elf File Generated

Open STMCubeProgrammer and Connect to STM Board Via USB

Screenshot 2024-05-06 213008.png

Open STMCubeProgrammer and Connect to STM Board Via USB

Screenshot 2024-05-06 213045.png

: Go to Download Options

Change Download Options and Click on "Start Automatic Mode"

Screenshot 2024-05-06 213208.png