通過單片機控制跑馬燈的明亮
STM32源程序如下:
- //相關頭文件包含
- #include "delay.h"
- #include "sys.h"
- #include "led.h"
- #include "key.h"
- int main(void)
- {
- delay_init();
- LED_Init();
- Key_GPIO_Config();
- while(1)
- {
- if(Key_Scan(GPIOC,GPIO_Pin_0)==0)
- {
- GPIO_SetBits(GPIOC,GPIO_Pin_2);
- delay_ms (300);
- GPIO_ResetBits(GPIOC,GPIO_Pin_2);
- GPIO_SetBits(GPIOC,GPIO_Pin_3);
- delay_ms (300);
- GPIO_ResetBits(GPIOC,GPIO_Pin_3);
- GPIO_SetBits(GPIOC,GPIO_Pin_4);
- delay_ms (300);
- GPIO_ResetBits(GPIOC,GPIO_Pin_4);
- GPIO_SetBits(GPIOC,GPIO_Pin_5);
- delay_ms (300);
- GPIO_ResetBits(GPIOC,GPIO_Pin_5);
- GPIO_SetBits(GPIOC,GPIO_Pin_6);
- delay_ms (300);
- GPIO_ResetBits(GPIOC,GPIO_Pin_6);
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
獨立按鍵.zip
(344.15 KB, 下載次數: 32)
2017-6-26 16:47 上傳
點擊文件名下載附件
|