以下是使用 STM32F103C8T6 全部引脚的 LED 流水灯程序:

#include "stm32f10x.h"

int main(void)
{
    /* Enable GPIOC clock */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

    /* Configure all pins of GPIOC as output push-pull */
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOC, &GPIO_InitStructure);

    while (1)
    {
        /* Turn on all LEDs */
        GPIO_SetBits(GPIOC, GPIO_Pin_All);
        /* Delay */
        for (int i = 0; i < 1000000; i++);
        /* Turn off all LEDs */
        GPIO_ResetBits(GPIOC, GPIO_Pin_All);
        /* Delay */
        for (int i = 0; i < 1000000; i++);
    }
}

该程序使用了 STM32F103C8T6 的全部引脚作为 LED 控制引脚,每次循环都会先将所有 LED 点亮,然后延时一段时间,再将所有 LED 熄灭,再延时一段时间,如此循环。通过这种方式,便可以实现 LED 流水灯效果。

STM32F103C8T6 全部引脚 LED 流水灯程序

原文地址: https://www.cveoy.top/t/topic/oSWL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录