MSP430流水灯Ⅰ
扫描二维码
随时随地手机看文章
#include
unsigned char LED;
unsigned int table[8] = {BIT0,BIT1,BIT2,BIT3,BIT4,BIT5,BIT6,BIT7};
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
LED = 0XFF;
P2DIR = 0XFF;
P2OUT = LED;
while(1)
{
unsigned int i,j;
for(i=0;i<8;i++)
{
LED = LED ^table[i];
P2OUT = LED;
LED = 0XFF;
j = 50000;
while(j--);
}
for(i=0;i<8;i++)
{
// LED ^= table[8-i];
LED ^= table[7-i];
P2OUT = LED;
LED = 0XFF;
j = 50000;
while(j--);
}
}
}