标题:
LED点阵屏时钟源程序 stc11f32xe
[打印本页]
作者:
51hei丽人
时间:
2016-6-21 01:05
标题:
LED点阵屏时钟源程序 stc11f32xe
由于时间问题,暂时还没有上传图片。
/********************************************************************
作者:TZR
版本:CLK188
简介:点阵屏很暗,只能在暗处看清。
*********************************************************************/
#include <at89x52.h>
sbit a1=P0^0;
sbit a2=P0^1;
sbit a3=P0^2;
sbit a4=P0^3;
sbit a5=P0^4;
sbit a6=P0^5;
sbit a7=P0^6;
sbit a8=P0^7;
sbit LED=P2^0;
sbit mode=P2^2;
sbit chan=P2^5;
P1M1=0x00;
P1M0=0xff;
bit rs;
unsigned int tt;
unsigned char syst;
unsigned char sec;
unsigned char min;
unsigned char hour;
unsigned char c;
unsigned char k;
unsigned char j;
unsigned char zt;
unsigned char temp;
unsigned char temp2;
unsigned char temp3;
unsigned char ledplay[7]={0+52,0+52,62,0+52,0+52,63,63};
unsigned char msg[4]={
64,19,25,17
};
unsigned char code word[][8]={
{0x20,0x50,0x88,0x88,0xF8,0x88,0x88,0x00}, // -A-0
{0xF0,0x88,0x88,0xF0,0x88,0x88,0xF0,0x00}, // -B-1
{0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00}, // -C-2
{0xF0,0x88,0x88,0x88,0x88,0x88,0xF0,0x00}, // -D-3
{0xF8,0x80,0x80,0xF0,0x80,0x80,0xF8,0x00}, // -E-4
{0xF8,0x80,0x80,0xF0,0x80,0x80,0x80,0x00}, // -F-5
{0x70,0x88,0x80,0x80,0xB8,0x88,0x78,0x00}, // -G-6
{0x88,0x88,0x88,0xF8,0x88,0x88,0x88,0x00}, // -H-7
{0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00}, // -I-8
{0x38,0x10,0x10,0x10,0x10,0x90,0x60,0x00}, // -J-9
{0x88,0x90,0xA0,0xC0,0xA0,0x90,0x88,0x00}, // -K-10
{0x80,0x80,0x80,0x80,0x80,0x80,0xF8,0x00}, // -L-11
{0x88,0xD8,0xA8,0xA8,0x88,0x88,0x88,0x00}, // -M-12
{0x88,0x88,0xC8,0xA8,0x98,0x88,0x88,0x00}, // -N-13
{0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00}, // -O-14
{0xF0,0x88,0x88,0xF0,0x80,0x80,0x80,0x00}, // -P-15
{0x70,0x88,0x88,0x88,0xA8,0x90,0x68,0x00}, // -Q-16
{0xF0,0x88,0x88,0xF0,0xA0,0x90,0x88,0x00}, // -R-17
{0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00}, // -S-18
{0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x00}, // -T-19
{0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00}, // -U-20
{0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00}, // -V-21
{0x88,0x88,0x88,0xA8,0xA8,0xD8,0x88,0x00}, // -W-22
{0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00}, // -X-23
{0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00}, // -Y-24
{0xF8,0x08,0x10,0x20,0x40,0x80,0xF8,0x00}, // -Z-25
{0x00,0x00,0xE0,0x10,0x70,0x90,0x68,0x00}, // -a-26
{0x80,0x80,0xB0,0xC8,0x88,0xC8,0xB0,0x00}, // -b-27
{0x00,0x00,0x70,0x88,0x80,0x80,0x70,0x00}, // -c-28
{0x08,0x08,0x68,0x98,0x88,0x98,0x68,0x00}, // -d-29
{0x00,0x00,0x70,0x88,0xF0,0x80,0x70,0x00}, // -e-30
{0x30,0x48,0x40,0xF0,0x40,0x40,0x40,0x00}, // -f-31
{0x00,0x00,0x70,0x88,0x88,0x78,0x08,0xF0}, // -g-32
{0x80,0x80,0xB0,0xC8,0x88,0x88,0x88,0x00}, // -h-33
{0x20,0x00,0x00,0x20,0x20,0x20,0x20,0x00}, // -i-34
{0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x60}, // -j-35
{0x80,0x80,0x90,0xA0,0xC0,0xA0,0x98,0x00}, // -k-36
{0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00}, // -l-37
{0x00,0x00,0x50,0xA8,0xA8,0xA8,0xA8,0x00}, // -m-38
{0x00,0x00,0xB0,0x48,0x48,0x48,0x48,0x00}, // -n-39
{0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00}, // -o-40
{0x00,0x00,0xF0,0x88,0x88,0xF0,0x80,0x80}, // -p-41
{0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08}, // -q-42
{0x00,0x00,0xB0,0x48,0x40,0x40,0x40,0x00}, // -r-43
{0x00,0x00,0x78,0x80,0x70,0x08,0xF0,0x00}, // -s-44
{0x40,0x40,0xF8,0x40,0x40,0x48,0x30,0x00}, // -t-45
{0x00,0x00,0x90,0x90,0x90,0x90,0x68,0x00}, // -u-46
{0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00}, // -v-47
{0x00,0x00,0xA8,0xA8,0xA8,0xA8,0x50,0x00}, // -w-48
{0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00}, // -x-49
{0x00,0x00,0x88,0x88,0x98,0x68,0x08,0xF0}, // -y-50
{0x00,0x00,0xF8,0x10,0x20,0x40,0xF8,0x00}, // -z-51
{0x38,0x44,0x4C,0x54,0x64,0x44,0x38,0x00}, // -0-52
{0x10,0x30,0x10,0x10,0x10,0x10,0x38,0x00}, // -1-53
{0x38,0x44,0x04,0x18,0x20,0x40,0x7C,0x00}, // -2-54
{0x7C,0x04,0x08,0x18,0x04,0x44,0x38,0x00}, // -3-55
{0x08,0x18,0x28,0x48,0x7C,0x08,0x08,0x00}, // -4-56
{0x7C,0x40,0x78,0x04,0x04,0x44,0x38,0x00}, // -5-57
{0x1C,0x20,0x40,0x78,0x44,0x44,0x38,0x00}, // -6-58
{0x7C,0x04,0x08,0x10,0x20,0x20,0x20,0x00}, // -7-59
{0x38,0x44,0x44,0x38,0x44,0x44,0x38,0x00}, // -8-60
{0x38,0x44,0x44,0x3C,0x04,0x08,0x30,0x00}, // -9-61
{0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00}, // -:-62
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // - -63
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, // -FULL-64
};
void delay (unsigned int a){
unsigned int i;
while(--a>0){
for(i=0;i<600;i++);
}
}
void ca(void){//ca=close all
P1=0x00;
}
void main (void){
mode=0;
chan=0;
zt=0;
LED=1;
syst=0;
EA=1;
ET0=1;
TH0 = 0x3c;
TL0 = 0xb0;
c=0;
TR0=1;
sec=0;
min=59;
hour=16;
tt=0;
rs=1;
while(1){/*
p=min/10;
if(tt>80){
p=min%10;
}
if(tt>160){
p=10;
}
if(tt>240){
p=sec/10;
}
if(tt>320){
p=sec%10;
}
if(tt>400){
p=11;
}
if(tt>480){
tt=0;
}*/
temp=0x80;
if(tt>60){
tt=0;
c++;
}
for(k=0;k<9;k++){
P0=~(temp);
if(rs==1){
temp2=word[msg[c]][k];
if(c==4){
c=0;
rs=0;
}
}else{
temp2=word[ledplay[c]][k];
if(c==7 && zt ==0){
c=0;
}
if(c==1 && zt !=0){
c=0;
}
}
for(j=0;j<9;j++){
temp3=temp2;
delay(1);
temp3>>=(8-j);
temp3<<=(8-j);
temp3>>=(tt/8);
temp3<<=(tt/8);
ca();
P1=temp3;
}
for(j=0;j<9;j++){
temp3=temp2;
delay(1);
temp3>>=(8-j);
temp3<<=(8-j);
temp3<<=(tt/8);
temp3>>=(tt/8);
ca();
P1=temp3;
}
temp>>=1;//换下一行
}
if(zt==0){
ledplay[0]=hour/10+52;
ledplay[1]=hour%10+52;
ledplay[2]=62;
ledplay[3]=min/10+52;
ledplay[4]=min%10+52;
ledplay[5]=63;
ledplay[6]=63;
ledplay[7]=63;
}
if(zt==1){
ledplay[0]=hour/10+52;
}
if(zt==2){
ledplay[0]=hour%10+52;
}
if(zt==3){
ledplay[0]=min/10+52;
}
if(zt==4){
ledplay[0]=min%10+52;
}/*
ledplay[8]=63;
ledplay[9]=63;
ledplay[0]=sec/10+52;
ledplay[1]=sec%10+52;*/
if(mode==1){
delay(30);
if(mode==1){
if(zt==0){
rs=1;
msg[0]=64;//Set
msg[1]=18;
msg[2]=30;
msg[3]=45;
}
zt++;
if(zt==5){
rs=1;
msg[0]=64;
msg[1]=14;
msg[2]=10;
msg[3]=63;
zt=0;
}
while(mode==1);
}
}
if(chan==1){
delay(30);
if(chan==1){
if(zt==1){
hour+=10;
if(hour>23){
hour=0;
}
}else if(zt==2){
hour+=1;
if(hour%10==0){
hour-=10;
}
}
if(zt==3){
min+=10;
if(min>59){
min=0;
}
}
if(zt==4){
min+=1;
if(min%10==0){
min-=0;
}
}
if(zt!=0){
sec=0;
}
while(chan==1);
}
}
}
}
void t0 (void) interrupt 1 using 3{
syst++;
if(syst>79){
syst=0;
sec++;
LED=~LED;
if(sec>59){
sec=0;
min++;
if(min>59){
min=0;
hour++;
if(hour>23){
hour=0;
/*day++;
if(day>29){
day=0;
month++;
if(month>12){
month=0;
year++;
//happy();
}
}*/
}
}
}
}
tt++;
TH0 = 0x31;
TL0 = 0x6d;
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1