Akhileshwar Thappa
Published

Led Blinking using STM32

The STM32 Black Pill and STM Cube IDE offer a simplified, cost-effective, and efficient solution for LED control and embedded system design

BeginnerFull instructions provided7
Led Blinking using STM32

Things used in this project

Hardware components

stm32f401ccu6
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Code

LED BLINK STM32

C/C++
#include "main.h"

class Delay {
public:
    void operator()(uint16_t time) {
        HAL_Delay(time);
    }
};

int main() {
    HAL_Init();
    SystemClock_Config();

    GPIO_InitTypeDef GPIO_InitStruct = {0};
    __HAL_RCC_GPIOA_CLK_ENABLE();

    GPIO_InitStruct.Pin = GPIO_PIN_5;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    Delay delay;

    while (1) {
        HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
        delay(1000);
    }
}

Credits

Akhileshwar Thappa

Akhileshwar Thappa

1 project • 0 followers

Comments