shaurya jain
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.

BeginnerFull instructions provided7
BLINK LED Using STM32

Things used in this project

Hardware components

STM 32 F401CCU6
×1
LED (generic)
LED (generic)
×1

Story

Read more

Code

LED BLINKING USING STM 32

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

shaurya jain

shaurya jain

2 projects • 0 followers

Comments