標(biāo)題: 基于stm32f103的跑馬燈源代碼 [打印本頁]

作者: pshh0420    時間: 2018-4-12 20:47
標(biāo)題: 基于stm32f103的跑馬燈源代碼
開發(fā)板是stm32f103
代碼不是原創(chuàng),純分享
大家一起學(xué)習(xí)

單片機(jī)源程序如下:
  1. #include "led.h"
  2. #include "delay.h"
  3. #include "sys.h"

  4. int main(void)
  5. {       
  6.         delay_init();                     //延時函數(shù)初始化          
  7.         LED_Init();                          //初始化與LED連接的硬件接口
  8.         while(1)
  9.         {
  10.                 GPIO_ResetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
  11.                 GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
  12.                 delay_ms(300);
  13.                 GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
  14.                 GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
  15.                 delay_ms(300);

  16.                 GPIO_ResetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
  17.                 GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
  18.                 delay_ms(300);
  19.                 GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
  20.                 GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
  21.                 delay_ms(300);
  22.                
  23.                 GPIO_SetBits(GPIOA,GPIO_Pin_8);//LED0輸出高
  24.                 GPIO_ResetBits(GPIOD,GPIO_Pin_2);//LED1輸出低
  25.                 delay_ms(300);
  26.                
  27.                 GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
  28.                 GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
  29.                 delay_ms(300);       

  30.                 GPIO_SetBits(GPIOA,GPIO_Pin_8);//LED0輸出高
  31.                 GPIO_ResetBits(GPIOD,GPIO_Pin_2);//LED1輸出低
  32.                 delay_ms(300);
  33.                
  34.                 GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
  35.                 GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
  36.                 delay_ms(300);       
  37.                
  38.         }
  39. }

復(fù)制代碼

所有資料51hei提供下載:
跑馬燈.rar (273.12 KB, 下載次數(shù): 22)







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1