#include <ti/devices/msp432p4xx/driverlib/driverlib.h>spa
//設定用於鬥豔的LED燈的端口和管腳im
#define led1 GPIO_PORT_P1,GPIO_PIN0端口
#define led2 GPIO_PORT_P2,GPIO_PIN2vi
void light(int );while
void delay(int );co
void main(void)time
{void
GPIO_setAsOutputPin(led1);
GPIO_setAsOutputPin(led2);
//設置七種明暗等級,共13種狀態轉換
int level[]={24,20,16,12,8,4,0,4,8,12,16,20,24};
int i=0,j,len=13;
while(1)
{
for(i=0;i<len;i++)
for(j=0;j<10;j++)//使變化流暢
light(level[i]);
}
}
//經過控制延時長度不一樣產生明暗差別
void light(int level){
GPIO_setOutputHighOnPin(led1);
GPIO_setOutputLowOnPin(led2);
delay(level);
GPIO_setOutputLowOnPin(led1);
GPIO_setOutputHighOnPin(led2);
delay(24-level);
}
void delay(int time){
int i=320*time;
while(i--) ;
}