#include <msp430g2452.h>
#define keyin (P2IN & BIT3)
int n=0;
unsigned char shuzi[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
void delay(int z)
{
int n,m;
for(n=z;n>0;n--)
for(m=100;m>0;m--);
}
void dis(int x)
{
int shi,ge;
shi=x%10;
ge=x/10;
P2OUT=0X02;
P1OUT=shuzi[shi];
delay(10);
P2OUT=0X01;
P1OUT=shuzi[ge];
delay(10);
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR =0XFF;
P2DIR = 0X03;
P2DIR &= ~BIT3;
P2REN |= BIT3;
P2OUT |= BIT3;
while(1)
{
dis(n);
if(keyin == 0)
{
delay(10);
if(keyin == 0)
{
n++;
if(n==100)
n=0;
}
}
// else continue;
}
}
求大神指教
此帖出自
小平头技术问答
一周热门 更多>