#include"reg51.h"
#define smg P0
#define key P1
#define uchar unsigned char
#define uint unsigned int
unsigned char code sz[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(uchar k);
void main(void)
{
while(1)
{
switch(key)
{
case 0x01:
smg=~sz[1];break;
case 0x02:
smg=~sz[2];break;
case 0x04:
smg=~sz[3];break;
case 0x08:
smg=~sz[4];break;
case 0x10:
smg=~sz[5];break;
case 0x20:
smg=~sz[6];break;
case 0x40:
smg=~sz[7];break;
case 0x80:
smg=~sz[8];break;
}
}
}
程序下载到单片机上,好像不运行
|