#include <msp430x14x.h>
#define uchar unsigned char
#define uint unsigned int
uchar num[8]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
void delay( void )
{
uint i, j;
for(i = 0; i < 30000; i++)
for(j = 0; j < 500; j++);
}
void main( void )
{
uchar z;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P2DIR = 0XFF;
while(1)
{
for(z = 0; z < 8; z++)
{
P2OUT = num[z];
delay();
}
}
}
为什么P2口上的8个LED全亮了?下面的程序为什么能实现流水灯而上面的不行呢?
#include <msp430x14x.h>
#define uchar unsigned char
#define uint unsigned int
uchar num[8]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
void delay( uint time )
{
uint i, j;
for(i = 0; i < time; i++)
for(j = 0; j < 500; j++);
}
void main( void )
{
uchar z;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P2DIR = 0XFF;
while(1)
{
for(z = 0; z < 8; z++)
{
P2OUT = num[z];
delay(30000);
}
}
}
此帖出自
小平头技术问答
是不是这个有问题啊
一周热门 更多>