IMPLEMENTING AN LED BLINKING EXPERIMENT

by GUMNAAM in Circuits > Electronics

51 Views, 1 Favorites, 0 Comments

IMPLEMENTING AN LED BLINKING EXPERIMENT

WhatsApp Image 2024-05-05 at 14.32.43_4c155a7e.jpg

With STM32 black pill and STM cube IDE to implement a sequence where three LEDs blink in various combinations

In this tutorial, we will delve into programming the STM32 "Black Pill" development board using STM32CubeIDE to create diverse LED blinking patterns. The Black Pill board employs the STM32F103C8T6 microcontroller, while STM32CubeIDE serves as a robust integrated development environment tailored for STM32 microcontrollers.

Supplies

  1. STM32 Black pill
  2. 3Led's
  3. Breadboard
  4. Jumper Wire
  5. USB type C cable
  6. STM 32 Cube ide
  7. STM 32 Cube Programmer

Setting Up Stm Cube IDE

WhatsApp Image 2024-05-05 at 14.41.17_949331d9.jpg
  1. Download and install STM32CubeIDE on your computer.
  2. Launch STM32CubeIDE and initiate a new project. a. Select "New STM32 Project" from the Quick Start menu. b. Choose your board or microcontroller (STM32F103C8) and proceed with the Next option. c. Configure project name and location, then click Finish.


PINOUT Configuration

WhatsApp Image 2024-05-05 at 18.21.31_8220cfd7.jpg
WhatsApp Image 2024-05-05 at 18.24.35_1b3a71e9.jpg
  • Select RCC from System Core.
  • Select the Cereamic/crystal response in High speed clock.
  • Some configurations wlll be added ,i.e,RCC_OSC_IN & RCC_OSC_OUT ON STM32 board of cubeide.
  • Select the Pins for output .(here I used PA10,PA11,PA12).


CLOCK CONFIGURATION

WhatsApp Image 2024-05-05 at 18.28.29_cd000db5.jpg
  • Select clock configuration.
  • Select HSE and PLLCLK in PLL Source MUX & System Clock MUX respectively.
  • Then select resolve clock issues


Write the Led Blinking Code

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,0);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,0);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,0);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,1);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,1);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,0);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,1);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,1);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,1);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,0);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,0);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,1);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,1);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,0);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,1);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,1);

HAL_Delay(1000);


Building the Project

  • Connect your STM32 Black Pill board to your computer using a USB cable.
  • Build the project by clicking on the hammer icon in the toolbar.
  • Once the build is successful, click the play (debug) button to flash the code onto the board.


Testing the Led Blinking Pattern

  1. Navigate to the "Core" folder in the project explorer and open main.c.
  2. Include necessary libraries and header files.


Led Blinking Results

WhatsApp Image 2024-05-05 at 17.54.32_19e55641.jpg

The STM32 Black Pill board to control LEDs in different blinking patterns using STM32CubeIDE. we can do further by adding new patterns or modifying the existing code to create more complex LED sequences.