Loading

LED流水灯

离
6月2日发布
#include "stm32f10x.h"                  // Device header
#include "Delay.h"
int main(void)
{
    // 1. 使能GPIOA时钟
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    // 2. 配置GPIOA的PA0引脚
  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;  // 配置为推挽输出模式
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;         // 选择PA0引脚
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // 设置输出速度为50MHz
  GPIO_Init(GPIOA, &GPIO_InitStructure);            // 初始化GPIOA的PA0引脚


    
  while(1)
    {
        
        GPIO_Write(GPIOA, ~0x0001);
        Delay_ms(500);
        GPIO_Write(GPIOA, ~0x0002);
        Delay_ms(500);
        GPIO_Write(GPIOA, ~0x0004);
        Delay_ms(500);
        GPIO_Write(GPIOA, ~0x0008);
        Delay_ms(500);
        
    }
}
© 版权声明
THE END
喜欢就支持一下吧
点赞 0 分享 收藏
评论 抢沙发
OωO
取消