科技学科吧 关注:12贴子:81
  • 0回复贴,共1
#include <reg51.h>
#define uchar unsigned char
sbit add=P2^7;
sbit jian=P2^6;
sbit clear=P2^5;
void delay(int t)
{
uchar i;
while(t--)
{
i=100;
while(i--);
}
}
main()
{
uchar tab[]={0x22,0xaf,0x31,0x25,0xac,0x64,0x60,0x2f,0x20,0x2c};
int i=0;
P0=0xff;
P2=0xfe;
while(1)
{
if(add!=1)
{P0=tab[i++];delay(1000);if(i>9) i=0;}
if(jian!=1)
{P0=tab[i--];delay(1000);if(i<0) i=9;}
if(clear!=1)
{i=0;P0=tab[i];delay(1000);}
}
}


IP属地:浙江1楼2014-05-20 22:46回复