完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
#include #define uchar unsigned char #define uint unsigned int ***it L_0=P0^0; ***it L_1=P0^1; ***it L_2=P0^2; ***it L_3=P0^3; ***it L_4=P0^4; ***it L_5=P0^5; ***it L_6=P0^6; ***it L_7=P0^7; ***it din=P3^5; ***it cs=P3^6; ***it clk=P3^7; uchar a,b,c,num=12,num1=0,num2=24; void delay(uint z) { uchar x,y; for(x=0;x } uchar keyscan() { uchar x,y,temp,buffer[]={0xfe,0xfd,0xfb,0xf7}; while(1) { for(x=0;x<4;x++) { P1=buffer[x]; temp=0x10; for(y=0;y<4;y++) { if(!(P1&temp)) { while(!(P1&temp)); return(4*x+y); } while(!(P1&temp)); temp<<=1; } } } } void max_byte(uchar x) { uchar i; cs=0; for(i=0;i<8;i++) { clk=0; din=(bit)(x&0x80); x<<=1; clk=1; } } void max(uchar x,uchar y) { cs=0; max_byte(x); max_byte(y); cs=1; } void init_7219() { max(0x09,0xff); max(0x0a,0x04); max(0x0b,0x07); max(0x0c,0x01); max(0x0f,0x00); } void init() { TMOD=0x11; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=(65536-50000)/256; TL1=(65536-50000)%256; ET1=1; TR1=1; ET0=1; TR0=1; } /*void init1() { TH1=(65536-50000)/256; TL1=(65536-50000)%256; ET1=1; TR1=1; } */ /*void ab() { if(num2>0&&num2<3) { P0=0x00; delay(800); P0=0xff; } } */ void ba() { if(num1==0) { num1=60; num--; } if(num==0 && num1<24) { ET0=0; } if(num==0&&num1==0) { P0=0x00; delay(200); P0=0xff; delay(200); P0=0x00; delay(200); P0=0xff; delay(200); P0=0x00; delay(200); P0=0xff; delay(200); } } void main() { uchar i, flag=0; init_7219(); init(); // init1(); EA=1; P1=0xf0; while(1) { if(P1!=0xf0) { delay(10); if(P1!=0xf0) { delay(10); if(P1!=0xf0) { i=keyscan(); switch(i) { case 0:flag=1;break; case 1:num=12;num1=0;break; case 2:flag=2;break; case 3:num2=24;break; } } } } max(8,num/10); max(7,num%10); max(6,15); max(5,num1/10); max(4,num1%10); max(3,15); max(2,num2/10); max(1,num2%10); if(flag==1) { TR1=~TR1; } if(flag==2) { TR0=~TR0; } } } void timer1() interrupt 1 { // uchar x; TH0=(65536-50000)/256; TL0=(65536-50000)%256; a++; if(a==20) { a=0; num2--; } // ab(); if(num2==0) { num2=24; } } void timer2() interrupt 3 { TH1=(65536-50000)/256; TL1=(65536-50000)%256; b++; if(b==20) { b=0; num1--; } ba(); } |
|
相关推荐
2 个讨论
|
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-21 08:18 , Processed in 0.595365 second(s), Total 60, Slave 45 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号