编辑: Mckel0ve 2016-05-16
显示0-7 #include #define uint unsigned int #define uchar unsigned char sbit dula = P2^6;

sbit wela=P2^7;

uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};

uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

void delay(uint);

uchar i;

uchar num=0;

void main() { while(1) { for(i=0;

i0;

y--) {} } } 开关控制第一个灯亮同时六个数码管从0-F变化 #include #define uint unsigned int #define uchar unsigned char sbit dula = P2^6;

sbit wela=P2^7;

sbit d0=P1^0;

uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};

//uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

void delay(uint);

uchar num;

void main() { EA=1;

EX0=1;

IT0=1;

wela=1;

P0=0xc0;

//同时选中8个数码管 wela=0;

while(1) { for(num=0;

num0;

x--) { for(y=110;

y>

0;

y--) {} } } void int0() interrupt

0 { d0=0;

} 流水灯轮流亮,六个数码管0-F变化,都是一秒一次 #include #include #define uint unsigned int #define uchar unsigned char sbit dula = P2^6;

sbit wela=P2^7;

uchar num,a,temp;

uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};

void delay(uint z) { uint x,y;

for(x=z;

x>

0;

x--) { for(y=110;

y>

0;

y--) {} } } void main() { a=0;

num=0;

TMOD=0X01;

//计时器工作在方式1 TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

EA=1;

//总中断允许 ET0=1;

TR0=1;

//启动计时器0 dula=1;

P0=table[0];

dula=0;

wela=1;

P0=0xc0;

wela=0;

temp=0xfe;

P1=temp;

while(1) { delay(1120);

temp=_crol_(temp,1);

P1=temp;

} } void timer0() interrupt

1 { TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

a++;

if(a==20) { a=0;

num++;

if(num==16){num=0;

} dula=1;

P0=table[num];

dula=0;

} } 动态显示123456 #include #define uint unsigned int #define uchar unsigned char sbit dula = P2^6;

sbit wela=P2^7;

//sbit d0=P1^0;

uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};

uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

uchar numdu,numwe;

void main() { numdu=0;

numwe=1;

TMOD=0X01;

TH0=(65536-151000)/256;

TL0=(65536-151000)%256;

EA=1;

ET0=1;

TR0=1;

while(1) { } } void timer0() interrupt

1 { TH0=(65536-151000)/256;

TL0=(65536-151000)%256;

numdu++;

if(numdu==7) {numdu=1;

} dula=1;

P0=table[numdu];

dula=0;

if(numwe==8) {numwe=0;

} wela=1;

P0=table1[numwe];

wela=0;

numwe++;

} 流水HELLO #include #define uint unsigned int #define uchar unsigned char sbit dula = P2^6;

sbit wela=P2^7;

uchar code table[]={ 0x76,0x79,0x38,0x38, 0x3f,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};

uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

void delay(uint);

uchar numwe,numdu,i,j;

void main() { while(1) { if(i0;

y--) {} } } void display1(uint k) { shi=k/10;

ge=k%10;

} void display2(uint j) { shig=j/10;

geg=j%10;

} 中断数码管 Display写HELLO #include #define uint unsigned int #define uchar unsigned char sbit dula = P2^6;

sbit wela=P2^7;

uchar time;

uchar code table[]={ 0x76,0x79,0x38,0x38, 0x3f,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};

//uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

void delay(uint);

void display(uchar,uchar,uchar,uchar,uchar);

void main() { time=550;

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题