求分51单片机控制七段数码管显示的时钟电路 和程序 KEYVAL EQU 30HKEYTM EQU 31HKEYSCAN EQU 32HDAT EQU 33HSCANLED EQU 39HCLK EQU 77HSEC EQU 78HMIN EQU 79HHOUR EQU 7AHPAUSE BIT 00HDOT BIT 01HORG 0000HLJMP MAINORG 000BHLJMP T0ISR;50ms定时ORG 001BHLJMP T1ISR;扫描显示ORG 0030HMAIN:MOV SP,#5FHMOV TMOD,#11HMOV TH0,#03CHMOV TL0,#0B0HMOV TH1,#0ECHMOV TL1,#078HMOV KEYVAL,#0MOV SCANLED,#0MOV 33H,#10HMOV 34H,#10HMOV 35H,#10HMOV 36H,#10HMOV 37H,#10HMOV 38H,#10HMOV SEC,#0MOV MIN,#0MOV HOUR,#0MOV CLK,#0CLR PAUSESETB EASETB ET1SETB TR1LOOP:LCALL KEYSELMOV A,KEYVALCJNE A,#0FFH,LOOP1SJMP LOOPLOOP1:CJNE A,#10,LOOP2;“ON”启动SETB TR0SETB ET0SETB PAUSESJMP LOOPLOOP2:CJNE A,#11,LOOP3;“=”清零MOV SEC,#0MOV MIN,#0MOV HOUR,#0LCALL DISCHGSJMP LOOPLOOP3:CJNE A,#15,LOOP4;“+”暂停CLR TR0CLR ET0CLR PAUSESJMP LOOPLOOP4:CJNE A,#14,LOOP5;“-”清显示暂停MOV 33H,#10HMOV 34H,#10HMOV 35H,#10HMOV 36H,#10HMOV 37H,#10HMOV 38H,#10HCLR TR0CLR ET0CLR PAUSESJMP LOOPLOOP5:CJNE A,#10,LOOP6;。
现急需由51单片机控制,273锁存控制7段数码管显示子程序,P2口控制位选共四个数码管显示红绿灯的时间 用C写?还是汇编?
求51单片机的C程序,就是键盘控制这个一位七段数码管,按键按1按下数码管上能够显示1,按2就能从1变到2。 51单片机的C程序,4*4键盘控制这个八位七段数码管。可以参考一下includedefine uchar unsigned charuchar temp;int key1,key,disbuf;此表为 LED 的字模 0 1 2 3 4 5 6 7 8 9 a b c d e funsigned char code LED7Code[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};unsigned char ledx[8];bit s0,s1;void delay(uchar z){uchar i,j;for(i=0;i;i+)for(j=0;j;j+);}void scan()/要是按键了,扫描键盘编码值{P1=0xF0;delay(1);temp=P1;switch(temp){case 0xe0:key1=0;break;case 0xd0:key1=1;break;case 0xb0:key1=2;break;case 0x70:key1=3;break;}P1=0x0f;delay(1);temp=P1;switch(temp){case 0x0E:key=key1+0;break;case 0x0D:key=key1+4;break;case 0x0B:key=key1+8;break;case 0x07:key=key1+12;break;default:key=-1;}if((key1+1)&(key+1))disbuf=key;}void ejjc()/判断是否按键{P1=0xF0;if(P1。0xF0){ scan();s0=1;}else { s0=0;s1=1;}}void main(){uchar i;while(1){ejjc();if(s0=1&s1=1){s0=0;s1=0;for(i=0;i;i+){ ledx[i]=ledx[i+1];ledx[8]=disbuf;}}P0=0xff;P2=LED7Code[ledx[0]];P0=。
/51单片机控制3位7段共阴数码管 p0口控制 abcdefg dp,p2.0-p2.2控制123位,-注意:没有用P2.3。要使其间隔1S分别显示123,231,321,213.无限循环下列程序,经过仿真,符合要求。includedefine uchar unsigned charsbit bit1=P2^0;sbit bit2=P2^1;sbit bit3=P2^2;uchar code dulatab[]=数字编码0-9{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};void delay(uchar time){uchar i,j;for(i=0;i;i+)for(j=0;j;j+);}void disp_num(uchar a,b,c){uchar i;for(i=1;i;i+){P2=255;关显示.P0=dulatab[a];bit1=0;delay(4);P2=255;关显示.P0=dulatab[b];bit2=0;delay(4);P2=255;关显示.P0=dulatab[c];bit3=0;delay(4);}}void main(){while(1){要使其间隔1S分别显示123,231,321,213.无限循环.disp_num(1,2,3);disp_num(2,3,1);disp_num(3,2,1);disp_num(2,1,3);disp_num?还想显示?内容,楼主可自行编写.disp_num?}}
单片机4*4键盘控制四位7段数码管显示00-15问题,十位数字闪一闪后就不亮了,个位数字是对的 你的显示是动态的,必须时时扫描,也就是循环送显示数据,否则就无法正常显示,includesbit a=P3^4;sbit b=P3^5;sbit c=P3^6;sbit d=P3^7;sbit e=P2^0;sbit f=P2^1;sbit g=P2^2;sbit h=P2^3;sbit i=P2^6;sbit j=P2^7;bit flag;unsigned char flag;unsigned char code dcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0xff};unsigned char key;unsigned char t;unsigned char m,mm;void delay1ms(unsigned int x){unsigned char j;while(x-){for(j=0;j;j+){;}}}void t0isr()interrupt 1{TH0=(65536-5000)/256;TL0=(65536-5000)%256;flag=~flag;if(flag){e=0;f=0;g=1;h=0;P0=dcode[key/10];}else {e=0;f=0;g=0;h=1;P0=dcode[key%10];}}void main(void){TMOD=0x01;TH0=(65536-5000)/256;TL0=(65536-5000)%256;TR0=1;ET0=1;EA=1;while(1){P3=0xff;a=0;t=P3;t=t&0x0f;if(t。0x0f){ delay1ms(80);if(t。0x0f){t=P3;t=t&0x0f;if(t=0x0e){key=0;}if(t=0x0d){key=1;}if(t=0x0b){key=2;}if(t=0x07){key=3;}}}P3=0xff;b=0;t=P3;t=t&0x0f;if(t。0x0f){delay1ms(80);if(t。0x0f){t=P3;t=t&0x0f;if(t=0x0e){key=4;}if(t=0x0d){key=5;}if。
51单片机如何利用4个七段数码管采用动态显示显示4位数字,如2035 /*显示函数 函数名:display56()变量定义:unsigned char qian,bai,shi,ge;定义显示缓冲区unsigned char table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xa7};表:共阳数码管 0 1 2 3 4 5 6 7 8 9 c延时子函数,短暂延时void delay56(){unsigned char i56=210;while(i56-);}void display56(){P0=table[qian];查得千位,送P0SMG_q=0;打开千位数码管delay56();延时P0=255;防止数码管脏乱SMG_q=1;关闭数码管P0=table[bai];选择百位数码管SMG_b=0;delay56();延时P0=255;SMG_b=1;P0=table[shi];选择十位数码管SMG_s=0;delay56();P0=255;SMG_s=1;P0=table[ge];选择个位数码管,SMG_g=0;delay56();P0=255;SMG_g=1;}你想显示什么,分别为qian,bai,shi,ge
急急急急急………………求一个单片机做一个四个按键控制四个七段数码管显示的程序