#include "stm32f10x.h"

int main(void) { GPIO_InitTypeDef GPIO_InitStructure;

//使能GPIOA时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

//配置GPIOA.0为输出模式
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);

while(1)
{
    //点亮LED
    GPIO_SetBits(GPIOA, GPIO_Pin_0);
    //延时
    for(int i=0; i<1000000; i++);
    
    //熄灭LED
    GPIO_ResetBits(GPIOA, GPIO_Pin_0);
    //延时
    for(int i=0; i<1000000; i++);
}

}

写一段代码实现stm32控制LED亮灭

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

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