|
//*********************************************************************************************/
#include "stm32f10x.h" //STM32頭文件
#include "sys.h"
#include "delay.h"
#include "led.h"
int main (void){//主程序
//定義需要的變量
u8 MENU;
u16 t,i;
//初始化程序
RCC_Configuration(); //時(shí)鐘設(shè)置
LED_Init();
//設(shè)置變量的初始值
MENU = 0;
t = 1;
//主循環(huán)
while(1){
//菜單0
if(MENU == 0){ //變亮循環(huán)
for(i = 0; i < 10; i++){
GPIO_WriteBit(LEDPORT,LED1,(BitAction)(1)); //LED1接口輸出高電平1
delay_us(t); //延時(shí)
GPIO_WriteBit(LEDPORT,LED1,(BitAction)(0)); //LED1接口輸出低電平0
delay_us(501-t); //延時(shí)
}
t++;
if(t==500){
MENU = 1;
}
}
//菜單1
if(MENU == 1){ //變暗循環(huán)
for(i = 0; i < 10; i++){
GPIO_WriteBit(LEDPORT,LED1,(BitAction)(1)); //LED1接口輸出高電平1
delay_us(t); //延時(shí)
GPIO_WriteBit(LEDPORT,LED1,(BitAction)(0)); //LED1接口輸出低電平0
delay_us(501-t); //延時(shí)
}
t--;
if(t==1){
MENU = 0;
}
}
}
}
程序:
LED呼吸燈程序1.7z
(183.67 KB, 下載次數(shù): 24)
2021-1-22 14:03 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|