Piyush Kumar Singh
Published

Blink Led 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

BeginnerProtip1 hour16
Blink Led using stm32

Things used in this project

Hardware components

STM32F401CCU6
×1

Story

Read more

Code

Untitled file

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

Code for Blinking led

C/C++
No preview (download only).

Credits

Piyush Kumar Singh

Piyush Kumar Singh

1 project • 0 followers

Comments