通过单片机控制跑马灯的明亮
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)
|