找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4351|回復: 0
收起左側(cè)

基于stm32f103的跑馬燈源代碼

[復制鏈接]
ID:306902 發(fā)表于 2018-4-12 20:47 | 顯示全部樓層 |閱讀模式
開發(fā)板是stm32f103
代碼不是原創(chuàng),純分享
大家一起學習

單片機源程序如下:
  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. }

復制代碼

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


評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表