本帖最后由 梦想天空 于 2017-11-13 16:08 编辑
#include <reg52.h>
sbit button1=P1^0;
sbit button2=P1^1;
sbit button3=P1^2;
sbit button4=P1^3;
sbit button5=P1^4;
sbit button6=P1^5;
sbit button7=P1^6;
sbit button8=P1^7;
sbit k1=P3^7;
unsigned char x[]=
{
0xf3,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f
};
void main()#include <reg52.h>
sbit button1=P1^0;
sbit button2=P1^1;
sbit button3=P1^2;
sbit button4=P1^3;
sbit button5=P1^4;
sbit button6=P1^5;
sbit button7=P1^6;
sbit button8=P1^7;
sbit k1=P3^7;
unsigned char x[]=
{
0xf3,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f
};
void main()
{
unsigned int i;
P2=0x40;
i=0;
while(1)
{
if(i==0)
{
if(button1==0){i=1;}
if(button2==0){i=2;}
if(button3==0){i=3;}
if(button4==0){i=4;}
if(button5==0){i=5;} {
unsigned int i;
P2=0x40;
i=0;
while(1)
{
if(i==0)
{
if(button1==0){i=1;}
if(button2==0){i=2;}
if(button3==0){i=3;}
if(button4==0){i=4;}
if(button5==0){i=5;}
if(button6==0){i=6;}
if(button7==0){i=7;}
if(button8==0){i=8;} }
P2=x[i%10];
}
// if(k1==0)
// {
// if(k1==0);
// P2=0x40;
// }
}
|