開發板是stm32f103
代碼不是原創,純分享
大家一起學習
單片機源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "sys.h"
- int main(void)
- {
- delay_init(); //延時函數初始化
- LED_Init(); //初始化與LED連接的硬件接口
- while(1)
- {
- GPIO_ResetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
- GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
- delay_ms(300);
- GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
- GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
- delay_ms(300);
- GPIO_ResetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
- GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
- delay_ms(300);
- GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
- GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
- delay_ms(300);
-
- GPIO_SetBits(GPIOA,GPIO_Pin_8);//LED0輸出高
- GPIO_ResetBits(GPIOD,GPIO_Pin_2);//LED1輸出低
- delay_ms(300);
-
- GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
- GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
- delay_ms(300);
- GPIO_SetBits(GPIOA,GPIO_Pin_8);//LED0輸出高
- GPIO_ResetBits(GPIOD,GPIO_Pin_2);//LED1輸出低
- delay_ms(300);
-
- GPIO_SetBits(GPIOA,GPIO_Pin_8); //LED0輸出低
- GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1輸出高
- delay_ms(300);
-
- }
- }
復制代碼
所有資料51hei提供下載:
跑馬燈.rar
(273.12 KB, 下載次數: 22)
2018-4-13 01:29 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|