导航:首页 > 操作系统 > 基于单片机的简易时钟设计

基于单片机的简易时钟设计

发布时间:2023-01-24 20:21:28

㈠ 利用AT89C51单片机设计简易电子钟(六位),通过8位LED数码管实现时间显示;系统可以通过三个按键实现时间


程序设计思路:1.利用单片机内部定时器作为计时器,调用timer函数;2、设计一套按键子程序;(3)设计一套数码显示管子程序。下列提供一套程序供参考。


#include<iom16v.h>

#include <macros.h>

#define uchar unsigned char

#define uint unsigned int


const uchar table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//0-9对应字符

const uchar key_value[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

uchar data[4]={0}; //显示初始值为0

uint count=0; //初始计数值为0

uchar keynum;



void port_init() //端口初始化函数

{DDRA=0XFF; //端口A为推挽1输出

PORTA=0XFF;

PORTB=0XFF; //端口B为推挽1输出

DDRB=0XFF;

DDRC=0XFF; //端口C为不带上拉电阻的输入

PORTC=0XFF;

DDRD=0XFF; //端口D低4位为输出

PORTD=0X0F;

}



void delay(uint j) //延时函数

{uint k;

while(j--)

{for(k=1000;k>0;k--) ;}

}



void display(uchar *p) //显示函数

{uchar i,sel=0x01;

for(i=0;i<4;i++)

{PORTA=sel; //选通最右边的数码管

PORTB=table[p[i]]; //送字型码

delay(1);

sel=sel<<1; //左移一位

}

}



uchar get_key(void)

{if((PIND&0X0F)!=0X0F) delay(3);

{

PORTD=0XEF;

switch(PIND&0X0F)

{case 0x0e: keynum=key_value[0];break;

case 0x0d: keynum=key_value[4];break;

case 0x0b: keynum=key_value[8];break;

case 0x07: keynum=key_value[12];break;

default:break;

}

PORTD=0xdf;

switch(PIND&0X0F)

{case 0x0e:keynum=key_value[1];break;

case 0x0d:keynum=key_value[5];break;

case 0x0b:keynum=key_value[9];break;

case 0x07:keynum=key_value[13];break;

default:break;

}


PORTD=0xbf;

switch(PIND&0X0F)

{case 0x0e:keynum=key_value[2];break;

case 0x0d:keynum=key_value[6];break;

case 0x0b:keynum=key_value[10];break;

case 0x07:keynum=key_value[14];break;

default:break;

}

PORTD=0x7f;

switch(PIND&0X0F)

{case 0x0e:keynum=key_value[3];break;

case 0x0d:keynum=key_value[7];break;

case 0x0b:keynum=key_value[11];break;

case 0x07:keynum=key_value[15];break;

default:break;

}

while((PIND&0x0f)!=0x0f);

}


return keynum;

}


void process(uint i,uchar *q) //拆分BCD码函数,显示千、百、十、个位

{ q[0]=i/1000;

i=i%1000;

q[1]=i/100;

i=i%100;

q[2]=i/10;

i=i%10;

q[3]=i;

}


void main(void)

{port_init();

PORTB=0xff;

PORTA=0X00;

delay(50);

PORTA=0xff;

while(1)

{get_key();

count=keynum;

process(count,data);

display(data);

}

}

㈡ 单片机实现电子钟设计

你的分数给的太低了,没有人愿意为帮忙,这也从侧面看出你根本就没有学习过单片机,那么这毕业设计就没有多大意义,还不如去看看某些关于单片机应用设计的教材,那上面的例子都是很详细的,并且有源代码。

如果要简单,DS12C887+AT89S52+LCD1602就足够了,汇编代码的长度不会超过200行。

㈢ 求一段为51单片机编写的LCD电子时钟的设计,简单就好!高分伺候!

简单的时钟,不用1302即可办到。

题目要求的设计已经完成,电路图如下。

程序稍长,放在我的网络空间了。

可以用网络、网页,进行查找:

做而论道用LCD1602显示的时钟

网络一下,即可查到。

㈣ 单片机电子时钟设计

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>#define INT8U unsigned char
#define INT16U unsigned int
#define k1() ((PIND & (1<<PD0))==0x00)
#define k2() ((PIND & (1<<PD1))==0x00)
#define k3() ((PIND & (1<<PD2))==0x00)
#define k4() ((PIND & (1<<PD3))==0x00)
#define k5() ((PIND & (1<<PD4))==0x00)
#define k6() ((PIND & (1<<PD5))==0x00)
#define k7() ((PIND & (1<<PD6))==0x00)
#define k8() ((PIND & (1<<PD7))==0x00)const INT8U seg[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x00};
INT8U seg11[]={0,0,0x40,0,0,0x40,0,0};
INT8U ja;
INT8U key=0xff;
INT8U h,m,s,m1,d;
INT16U y; void hour1()
{
if (++h>23) {h=0;day();}
seg11[0]=seg[h/10];
seg11[1]=seg[h%10];
} void minute1()
{
if (++m>59)
{m=0;<br> hour1();<br> }
seg11[3]=seg[m/10];
seg11[4]=seg[m%10];
} void second1() {
if (++s>59)
{ s=0;
minute1();
}
seg11[6]=seg[s/10];
seg11[7]=seg[s%10];
} const INT8U Days1[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
const INT8U Days2[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
void year()
{if (++y>9999) y=0;<br> <br> seg11[0]=seg[y/1000];<br> seg11[1]=seg[y%1000/100];<br> seg11[2]=seg[y%100/10];<br> seg11[3]=seg[y%10];<br> } void month1()
{
if (++m1>12)
{m1=0;<br> year();<br> }
seg11[4]=seg[m1/10];
seg11[5]=seg[m1%10];
} void day()
{ INT8U DAY;
DAY=(( y%4==0 && y%100!=0 )||( y%400==0 ) ) ? Days1[m1]:Days2[m1];//判断闰年
if(++d>DAY)

{ d=0;
month1();

}
seg11[6]=seg[d/10];
seg11[7]=seg[d%10];
} //时间函数
void time()
{
seg11[0]=seg[h/10];
seg11[1]=seg[h%10];
seg11[3]=seg[m/10];
seg11[4]=seg[m%10];
seg11[6]=seg[s/10];
seg11[7]=seg[s%10];
PORTA=0x00;
PORTA=seg11[ja]; PORTB=~(1<<ja);
ja=(ja+1)&0x07;
_delay_ms(5); }
//日期
void date()
{ seg11[0]=seg[y/1000];
seg11[1]=seg[y%1000/100];
seg11[2]=seg[y%100/10];
seg11[3]=seg[y%10];

seg11[4]=seg[m1/10];
seg11[5]=seg[m1%10];
seg11[6]=seg[d/10];
seg11[7]=seg[d%10];
//seg11[2]=seg11[5]=0x00;
PORTA=0x00;
PORTA=seg11[ja];
PORTB=~(1<<ja);
ja=(ja+1)&0x07;
_delay_ms(3);
}
int main()
{ INT8U ja=0;
DDRA=0xff; PORTA=0xff;
DDRB=0xff; PORTB=0xff;
DDRD=0x00; PORTD=0xff;PIND=0x00;

MCUCR=0X0A;//MCU 控制寄存器- MCUCR
GICR=0XC0; //通用中断控制寄存器- GICR ASSR=0x08;
TCCR2=0x04;
TCNT2=0;
TIMSK=_BV(TOIE2)|_BV(TOIE0); d=26;y=2000;m1=2;
h=m=s=12;
sei();
while(1)
{ time();

if(k1())
/{ while(k1()); hour1(); }

if(k8())
{ while(k8());

while(2)//日期循环
{

date();
if(k8())
{while(k8());break;} }
}
}}
ISR(TIMER2_OVF_vect) {
if( seg11[2]==0x40)
{
seg11[2]=seg11[5]=0x00;
}

else
{ seg11[2]=seg11[5]=0x40;
second1();
}
}

㈤ 基于AT89C51单片机的6位数码管显示的简易电子时钟设计

#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit ds1302_RST =P2^0;
sbit ds1302_IO =P2^1;
sbit ds1302_SCLK=P2^2;
sbit ACC0=ACC^0;
sbit ACC7=ACC^7;
sbit A1=P3^0;
sbit A2=P3^1;
sbit A3=P3^2;
sbit A4=P3^3;
sbit A5=P3^4;
sbit A6=P3^5;
sbit key1=P3^6;
sbit key2=P3^7;
uchar now_time[3],wei,d[3]={0,0,0};
uchar code s[]={ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e
};
void delay(uint x)
{
uchar i;
for(x;x>0;x--)
for(i=0;i<100;i++);
}
void disp()
{
P1=s[now_time[2]/16];
A1=d[2];
delay(5);
A1=1;
P1=s[now_time[2]%16];
A2=d[2];
delay(5);
A2=1;
P1=s[now_time[1]/16];
A3=d[1];
delay(5);
A3=1;
P1=s[now_time[1]%16];
A4=d[1];
delay(5);
A4=1;
P1=s[now_time[0]/16];
A5=d[0];
delay(5);
A5=1;
P1=s[now_time[0]%16];
A6=d[0];
delay(5);
A6=1;
}
/***********************************************************************/
uchar read_Byte()
{
uchar i;
for(i=8;i>0;i--)
{
ACC=ACC>>1;
ACC7=ds1302_IO;
ds1302_SCLK=1;
ds1302_SCLK=0;
}
return(ACC);
}

void write_Byte(uchar tdata)
{
uchar i;
ACC=tdata;
for(i=8;i>0;i--)
{
ds1302_IO=ACC0;
ds1302_SCLK=1;
ds1302_SCLK=0;
ACC=ACC>>1;
}

}
/***********************************************************************************/
void write_data_ds1302(uchar taddr,uchar tdata)
{
ds1302_RST=0;
ds1302_SCLK=0;
ds1302_RST=1;
write_Byte(taddr);
write_Byte(tdata);
ds1302_RST=0;
ds1302_SCLK=1;
}

uchar read_data_ds1302(uchar taddr)
{
uchar tdata;

ds1302_RST=0;
ds1302_SCLK=0;
ds1302_RST=1;
write_Byte(taddr);
tdata=read_Byte();
ds1302_RST=0;
ds1302_SCLK=1;
return(tdata);
}
/***********************************************************************************/

void get_ds1302()
{
uchar k;
uchar taddr = 0x81;
for (k=0; k<3; k++)
{
now_time[k] = read_data_ds1302(taddr);
taddr+=2;

}
}
/***********************************************************************************/

void init_ds1302()
{
ds1302_RST=0;
ds1302_SCLK=0;
A1=1;
A2=1;
A3=1;
A4=1;
A5=1;
A6=1;
write_data_ds1302(0x80,0x00);
}
/***********************************************************************************/
void Time();
/***********************************************************************************/
main()
{
init_ds1302();

while(1)
{
disp();
get_ds1302();
if(key1==0);
{ delay(10);
if(key1==0)
Time();
}

}
}
void timer() interrupt 3
{
uchar i;i++;
TH1=(65535-50000)/256;
TL2=(65535-50000)%256;
if(i==50)
{
d[wei]=1;
}
if(i==100)
{ i=0;
d[wei]=0;
}
}
/***********************************************************************************/

void Time()
{
uchar temp;
uint r=0,p=1;
wei=2;
TMOD=0x01;
EA=1;
ET1=1;
TH1=(65535-50000)/256;
TL2=(65535-50000)%256;
TR1=1;
for(r=0;r<50;r++)
disp();

while( key1 )
{
wei=2;
disp();
if(key2==0)
{
disp();
if(key2==0)
{
temp=now_time[2]/16*10+now_time[2]%16;
temp++;
if(temp>=24)
temp=0;
now_time[2]=temp/10*16+temp%10;
write_data_ds1302(0x84,now_time[2]);
}
while(!key2);

}

}
wei=1;
d[2]=0;
for(r=0;r<50;r++)
disp();

while(key1 )
{ disp();
if(key2==0)
{
disp();
if(key2==0)
{
temp=now_time[1]/16*10+now_time[1]%16;
temp++;
if(temp>=60)
temp=0;
now_time[1]=temp/10*16+temp%10;
write_data_ds1302(0x82,now_time[1]);
}
while(!key2);
}
}
wei=0;
d[1]=0;

for(r=0;r<50;r++)
disp();

while(key1 )
{
disp();
if(key2==0)
{
now_time[0]=0;
write_data_ds1302(0x80,now_time[0]);
}

} TR1=0;

d[0]=0;
for(r=0;r<30;r++)
disp();

}

/*********************************************************************************/

㈥ 用单片机设计一个数字时钟

#include <REG51.H>#include <intrins.h> #define uint unsigned int#define uchar unsigned charsbit DS1302_CLK = P1^7; //实时时钟时钟线引脚 sbit DS1302_IO = P1^6; //实时时钟数据线引脚 sbit DS1302_RST = P1^5; //实时时钟复位线引脚sbit wireless_1 = P3^0;sbit wireless_2 = P3^1;sbit wireless_3 = P3^2;sbit wireless_4 = P3^3; //无线控制sbit ACC0 = ACC^0;sbit ACC7 = ACC^7;char hide_sec,hide_min,hide_hour,hide_day,hide_week,hide_month,hide_year; //秒,分,时到日,月,年位闪的计数sbit Set = P2^0; //模式切换键sbit Up = P2^1; //加法按钮sbit Down = P2^2; //减法按钮sbit out = P2^3; //立刻跳出调整模式按钮sbit DQ = P1^0; //温度传送数据IO口char done,count,temp,flag,up_flag,down_flag;uchar temp_value; //温度值uchar TempBuffer[5],week_value[2]; void show_time(); //液晶显示程序/***********1602液晶显示部分子程序****************///Port Definitions**********************************************************sbit LcdRs = P2^5;sbit LcdRw = P2^6;sbit LcdEn = P2^7;sfr DBPort = 0x80; //P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.数据端口 //内部等待函数**************************************************************************unsigned char LCD_Wait(void){ LcdRs=0; LcdRw=1; _nop_(); LcdEn=1; _nop_(); LcdEn=0; return DBPort; }//向LCD写入命令或数据************************************************************#define LCD_COMMAND 0 // Command#define LCD_DATA 1 // Data#define LCD_CLEAR_SCREEN 0x01 // 清屏#define LCD_HOMING 0x02 // 光标返回原点void LCD_Write(bit style, unsigned char input){ LcdEn=0; LcdRs=style; LcdRw=0; _nop_(); DBPort=input; _nop_();//注意顺序 LcdEn=1; _nop_();//注意顺序 LcdEn=0; _nop_(); LCD_Wait(); } //设置显示模式************************************************************#define LCD_SHOW 0x04 //显示开#define LCD_HIDE 0x00 //显示关 #define LCD_CURSOR 0x02 //显示光标#define LCD_NO_CURSOR 0x00 //无光标 #define LCD_FLASH 0x01 //光标闪动#define LCD_NO_FLASH 0x00 //光标不闪动 void LCD_SetDisplay(unsigned char DisplayMode){ LCD_Write(LCD_COMMAND, 0x08|DisplayMode); } //设置输入模式************************************************************#define LCD_AC_UP 0x02#define LCD_AC_DOWN 0x00 // default #define LCD_MOVE 0x01 // 画面可平移#define LCD_NO_MOVE 0x00 //default void LCD_SetInput(unsigned char InputMode){ LCD_Write(LCD_COMMAND, 0x04|InputMode);} //初始化LCD************************************void LCD_Initial(){ LcdEn=0; LCD_Write(LCD_COMMAND,0x38); //8位数据端口,2行显示,5*7点阵 LCD_SetDisplay(LCD_SHOW|LCD_NO_CURSOR); //开启显示, 无光标 LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏 LCD_SetInput(LCD_AC_UP|LCD_NO_MOVE); //AC递增, 画面不动} //液晶字符输入的位置************************void GotoXY(unsigned char x, unsigned char y){ if(y==0) LCD_Write(LCD_COMMAND,0x80|x); if(y==1) LCD_Write(LCD_COMMAND,0x80|(x-0x40));} //将字符输出到液晶显示void Print(unsigned char *str){ while(*str!='\0') { LCD_Write(LCD_DATA,*str); str++; }} /***********DS1302时钟部分子程序******************/typedef struct __SYSTEMTIME__{ unsigned char Second; unsigned char Minute; unsigned char Hour; unsigned char Week; unsigned char Day; unsigned char Month; unsigned char Year; unsigned char DateString[11]; unsigned char TimeString[9];}SYSTEMTIME; //定义的时间类型SYSTEMTIME CurrentTime; #define AM(X) X#define PM(X) (X+12) // 转成24小时制#define DS1302_SECOND 0x80 //时钟芯片的寄存器位置,存放时间#define DS1302_MINUTE 0x82#define DS1302_HOUR 0x84 #define DS1302_WEEK 0x8A#define DS1302_DAY 0x86#define DS1302_MONTH 0x88#define DS1302_YEAR 0x8C void DS1302InputByte(unsigned char d) //实时时钟写入一字节(内部函数){ unsigned char i; ACC = d; for(i=8; i>0; i--) { DS1302_IO = ACC0; //相当于汇编中的 RRC DS1302_CLK = 1; DS1302_CLK = 0; ACC = ACC >> 1; } } unsigned char DS1302OutputByte(void) //实时时钟读取一字节(内部函数){ unsigned char i; for(i=8; i>0; i--) { ACC = ACC >>1; //相当于汇编中的 RRC ACC7 = DS1302_IO; DS1302_CLK = 1; DS1302_CLK = 0; } return(ACC); } void Write1302(unsigned char ucAddr, unsigned char ucDa) //ucAddr: DS1302地址, ucData: 要写的数据{ DS1302_RST = 0; DS1302_CLK = 0; DS1302_RST = 1; DS1302InputByte(ucAddr); // 地址,命令 DS1302InputByte(ucDa); // 写1Byte数据 DS1302_CLK = 1; DS1302_RST = 0;} unsigned char Read1302(unsigned char ucAddr) //读取DS1302某地址的数据{ unsigned char ucData; DS1302_RST = 0; DS1302_CLK = 0; DS1302_RST = 1; DS1302InputByte(ucAddr|0x01); // 地址,命令 ucData = DS1302OutputByte(); // 读1Byte数据 DS1302_CLK = 1; DS1302_RST = 0; return(ucData);} void DS1302_GetTime(SYSTEMTIME *Time) //获取时钟芯片的时钟数据到自定义的结构型数组{ unsigned char ReadValue; ReadValue = Read1302(DS1302_SECOND); Time->Second = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); ReadValue = Read1302(DS1302_MINUTE); Time->Minute = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); ReadValue = Read1302(DS1302_HOUR); Time->Hour = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); ReadValue = Read1302(DS1302_DAY); Time->Day = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); ReadValue = Read1302(DS1302_WEEK); Time->Week = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); ReadValue = Read1302(DS1302_MONTH); Time->Month = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); ReadValue = Read1302(DS1302_YEAR); Time->Year = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F); } void DateToStr(SYSTEMTIME *Time) //将时间年,月,日,星期数据转换成液晶显示字符串,放到数组里DateString[]{ if(hide_year<2) //这里的if,else语句都是判断位闪烁,<2显示数据,>2就不显示,输出字符串为 2007/07/22 { Time->DateString[0] = '2'; Time->DateString[1] = '0'; Time->DateString[2] = Time->Year/10 + '0'; Time->DateString[3] = Time->Year%10 + '0'; } else { Time->DateString[0] = ' '; Time->DateString[1] = ' '; Time->DateString[2] = ' '; Time->DateString[3] = ' '; } Time->DateString[4] = '/'; if(hide_month<2) { Time->DateString[5] = Time->Month/10 + '0'; Time->DateString[6] = Time->Month%10 + '0'; } else { Time->DateString[5] = ' '; Time->DateString[6] = ' '; } Time->DateString[7] = '/'; if(hide_day<2) { Time->DateString[8] = Time->Day/10 + '0'; Time->DateString[9] = Time->Day%10 + '0'; } else { Time->DateString[8] = ' '; Time->DateString[9] = ' '; } if(hide_week<2) { week_value[0] = Time->Week%10 + '0'; //星期的数据另外放到 week_value[]数组里,跟年,月,日的分开存放,因为等一下要在最后显示 } else { week_value[0] = ' '; } week_value[1] = '\0'; Time->DateString[10] = '\0'; //字符串末尾加 '\0' ,判断结束字符} void TimeToStr(SYSTEMTIME *Time) //将时,分,秒数据转换成液晶显示字符放到数组 TimeString[];{ if(hide_hour<2) { Time->TimeString[0] = Time->Hour/10 + '0'; Time->TimeString[1] = Time->Hour%10 + '0'; } else { Time->TimeString[0] = ' '; Time->TimeString[1] = ' '; } Time->TimeString[2] = ':'; if(hide_min<2) { Time->TimeString[3] = Time->Minute/10 + '0'; Time->TimeString[4] = Time->Minute%10 + '0'; } else { Time->TimeString[3] = ' '; Time->TimeString[4] = ' '; } Time->TimeString[5] = ':'; if(hide_sec<2) { Time->TimeString[6] = Time->Second/10 + '0'; Time->TimeString[7] = Time->Second%10 + '0'; } else { Time->TimeString[6] = ' '; Time->TimeString[7] = ' '; } Time->DateString[8] = '\0';} void Initial_DS1302(void) //时钟芯片初始化{ unsigned char Second=Read1302(DS1302_SECOND); if(Second&0x80) //判断时钟芯片是否关闭 { Write1302(0x8e,0x00); //写入允许 Write1302(0x8c,0x07); //以下写入初始化时间 日期:07/07/25.星期: 3. 时间: 23:59:55 Write1302(0x88,0x07); Write1302(0x86,0x25); Write1302(0x8a,0x07); Write1302(0x84,0x23); Write1302(0x82,0x59); Write1302(0x80,0x55); Write1302(0x8e,0x80); //禁止写入 } } /***********ds18b20子程序*************************/ /***********ds18b20延迟子函数(晶振12MHz )*******/ void delay_18B20(unsigned int i){ while(i--);} /**********ds18b20初始化函数**********************/ void Init_DS18B20(void) { unsigned char x=0; DQ = 1; //DQ复位 delay_18B20(8); //稍做延时 DQ = 0; //单片机将DQ拉低 delay_18B20(80); //精确延时 大于 480us DQ = 1; //拉高总线 delay_18B20(14); x=DQ; //稍做延时后 如果x=0则初始化成功 x=1则初始化失败 delay_18B20(20);} /***********ds18b20读一个字节**************/ unsigned char ReadOneChar(void){ uchar i=0; uchar dat = 0; for (i=8;i>0;i--) { DQ = 0; // 给脉冲信号 dat>>=1; DQ = 1; // 给脉冲信号 if(DQ) dat|=0x80; delay_18B20(4); } return(dat);} /*************ds18b20写一个字节****************/ void WriteOneChar(uchar dat){ unsigned char i=0; for (i=8; i>0; i--) { DQ = 0; DQ = dat&0x01; delay_18B20(5); DQ = 1; dat>>=1; }} /**************读取ds18b20当前温度************/ void ReadTemp(void){ unsigned char a=0; unsigned char b=0; unsigned char t=0; Init_DS18B20(); WriteOneChar(0xCC); // 跳过读序号列号的操作 WriteOneChar(0x44); // 启动温度转换 delay_18B20(100); // this message is wery important Init_DS18B20(); WriteOneChar(0xCC); //跳过读序号列号的操作 WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器) 前两个就是温度 delay_18B20(100); a=ReadOneChar(); //读取温度值低位 b=ReadOneChar(); //读取温度值高位 temp_value=b<<4; temp_value+=(a&0xf0)>>4; }void temp_to_str() //温度数据转换成液晶字符显示{ TempBuffer[0]=temp_value/10+'0'; //十位 TempBuffer[1]=temp_value%10+'0'; //个位 TempBuffer[2]=0xdf; //温度符号 TempBuffer[3]='C'; TempBuffer[4]='\0';}void Delay1ms(unsigned int count){ unsigned int i,j; for(i=0;i<count;i++) for(j=0;j<120;j++);} /*延时子程序*/void mdelay(uint delay){ uint i; for(;delay>0;delay--) {for(i=0;i<62;i++) //1ms延时. {;} }}

㈦ 用单片机制作一个简易的时钟。。

#include<reg52.h>
#include"segnumca.h"
#define uchar unsigned char
sbit _speak=P1^0; //蜂鸣器P1^0
uchar hello_[]={0x89,0x86,0xc7,0xc7,0xc0,0xf7}; //HELLO_
uchar con[]={0x01,0x02,0x04,0x08,0x10,0x20}; //位控制
uchar time0=100;
uchar i=0;
uchar s,m,h;
void delay(); //0.3s
void intr_(); //int0\1初始化
/*********************************
主函数
*********************************/
void main()
{
s=m=h=0;
TMOD=0x01;
TH0=0x3c;
TL0=0xb0;
TR0=1;
ET0=1;
EA=1;
intr_();
while(time0>10)
{
P2=con[i];
P0=hello_[i];
i++;
if(i>=6)i=0;
delay();
}
i=0;
while(1)
{
P2=con[i];
switch(i)
{
case 0:P0=seg[h/10];break;
case 1:P0=seg[h%10]+0x80;break;
case 2:P0=seg[m/10];break;
case 3:P0=seg[m%10]+0x80;break;
case 4:P0=seg[s/10];break;
case 5:P0=seg[s%10];break;
}
i++;
if(i>=6)i=0;
delay();
}
}
/****************************
T0
****************************/
void isr_time0() interrupt 1
{
TH0=0x3c;
TL0=0xb0;
time0--;
if(!time0)
{
time0=20;
s++;
if(s>=60)
{
s=0;
m++;
if(m>=60)
{
m=0;
h++;
if(h>=24)
{
h=0;
}
}
}
}
}
/*************************
外中断初始化
*************************/
void intr_()
{
IT0=1;IT1=1;EX0=1;EX1=1;
}
/**************************
for延时
**************************/
void delay() //大约延时0.3秒
{
unsigned char delay0,delay1;
for(delay0=0;delay0<5;delay0++)
for(delay1=0;delay1<255;delay1++);
}
/*********************************************
INT0
*********************************************/
void intr_0() interrupt 0
{
m++;
if(m>=60)m=0;
}
/*********************************************
INT1
*********************************************/
void intr_1() interrupt 2
{
h++;
if(h>=24)h=0;
}

㈧ 求单片机简易数字钟的课程设计 :要求自制一个单片机最小系统,包括串口下载、复位电路,采用内部定时器计

下面的程序配合这个电路运行就是对的

这个是完整的程序,电路图如下

#include<reg52.h>

//定义共阳极字型码0123456789-

unsignedcharcodedispcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};

unsignedchartime[]={0,0,0,0};//用来储存分秒

unsignedchardate[]={0,0,0,0};//用来储存日时

unsignedcharyear[]={0,0,0,0};//用来储存年月

typedefstruct__SYSTEMTIME__

{

unsignedcharSecond;

unsignedcharMinute;

unsignedcharHour;

unsignedcharWeek;

unsignedcharDay;

unsignedcharMonth;

unsignedcharYear;

unsignedcharDateString[9];

unsignedcharTimeString[9];

}SYSTEMTIME; //定义的时间类型

SYSTEMTIMEtime1;

sbitDS1302_CLK=P1^6;//实时时钟时钟线引脚

sbitDS1302_IO=P1^7;//实时时钟数据线引脚

sbitDS1302_RST=P1^5;//实时时钟复位线引脚

sbitACC0=ACC^0;

sbitACC7=ACC^7;

sbitP10=P1^0;

sbitP11=P1^1;

sbitP12=P1^2;

sbitP13=P1^3;

sbitP14=P1^4;

//#defineAM(X) X

//#definePM(X) (X+12) //转成24小时制

#defineDS1302_SECOND 0x80//秒寄存器

#defineDS1302_MINUTE 0x82//分寄存器

#defineDS1302_HOUR 0x84

#defineDS1302_WEEK 0x8A

#defineDS1302_DAY 0x86

#defineDS1302_MONTH 0x88

#defineDS1302_YEAR 0x8C

#defineDS1302_RAM(X) (0xC0+(X)*2) //用于计算DS1302_RAM地址的宏

voidDS1302InputByte(unsignedchard) //实时时钟写入一字节(内部函数)

{

unsignedchari;

ACC=d;

for(i=8;i>0;i--)

{

DS1302_IO=ACC0; //相当于汇编中的RRC

DS1302_CLK=1;

DS1302_CLK=0;//发一个高跳变到低的脉冲

ACC=ACC>>1;

}

}

unsignedcharDS1302OutputByte(void) //实时时钟读取一字节(内部函数)

{

unsignedchari;

for(i=8;i>0;i--)

{

ACC=ACC>>1; //相当于汇编中的RRC

ACC7=DS1302_IO;

DS1302_CLK=1;

DS1302_CLK=0;//发一个高跳变到低的脉冲

}

return(ACC);

}

voidWrite1302(unsignedcharucAddr,unsignedcharucDa) //ucAddr:DS1302地址,ucData:要写的数据

{

DS1302_RST=0;

DS1302_CLK=0;

DS1302_RST=1;

DS1302InputByte(ucAddr); //地址,命令

DS1302InputByte(ucDa); //写1Byte数据

DS1302_CLK=1;

DS1302_RST=0;//RST0->1->0,CLK0->1

}

unsignedcharRead1302(unsignedcharucAddr) //读取DS1302某地址的数据

{

unsignedcharucData;

DS1302_RST=0;

DS1302_CLK=0;

DS1302_RST=1;//enable

DS1302InputByte(ucAddr|0x01);//地址,命令

ucData=DS1302OutputByte();//读1Byte数据

DS1302_CLK=1;//RST0->1->0,CLK0->1

DS1302_RST=0;

return(ucData);

}

voidDS1302_SetProtect(bitflag)//是否写保护

{

if(flag)

Write1302(0x8E,0x10);//WP=1,不能写入

else

Write1302(0x8E,0x00);//WP=0,可以写入

}

voidDS1302_SetTime(unsignedcharAddress,unsignedcharValue)//设置时间函数

{

DS1302_SetProtect(0);

Write1302(Address,((Value/10)<<4|(Value%10)));//高4位为十位,低4位为个位

}

voidDS1302_GetTime(SYSTEMTIME*Time)

{

unsignedcharReadValue;

ReadValue=Read1302(DS1302_SECOND);

Time->Second=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);//转换成10进制的秒

ReadValue=Read1302(DS1302_MINUTE);

Time->Minute=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);

ReadValue=Read1302(DS1302_HOUR);

Time->Hour=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);

ReadValue=Read1302(DS1302_DAY);

Time->Day=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);

ReadValue=Read1302(DS1302_WEEK);

Time->Week=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);

ReadValue=Read1302(DS1302_MONTH);

Time->Month=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);

ReadValue=Read1302(DS1302_YEAR);

Time->Year=((ReadValue&0xf0)>>4)*10+(ReadValue&0x0F);

}

voidInitial_DS1302(void)

{

unsignedcharSecond=Read1302(DS1302_SECOND);

if(Second&0x80)//如果第七为1(表明没有启动),则启动时钟

DS1302_SetTime(DS1302_SECOND,0);

}

voiddelay(unsignedchari)//延时子程序

{

unsignedcharj;

while((i--)!=0)

{

for(j=625;j>0;j--);

}

}

/*unsignedcharbutton_time(n,x,y)//时钟调整子程序

unsignedcharn,x,y;

{

if(P1^7==0)

{

delay(50);

if(P1^7==0)

{

n++;

if(n==x)

n=0;

while(P1^7==0);

}

}

if(P1^1==0)

{

delay(50);

if(P1^1==0)

{

if(n==0)

n=y;

else

n--;

while(P1^1==0);

}

}

returnn;

}

*/

/*unsignedcharbutton_date(n,x,y)//日期调整子程序

unsignedcharn,x,y;

{

if(P1^7==0)

{

delay(50);

if(P1^7==0)

{

n++;

if(n==x)

n=1;

while(P1^7==0);

}

}

if(P1^1==0)

{

delay(50);

if(P1^1==0)

{

if(n==1)

n=y;

else

n--;

while(P1^1==0);

}

}

returnn;

}*/

voiddisplay1(minute10,minute1,second10,second1) //显示第一页分秒子程序

//unsignedcharsecond10,second1,minute10,minute1;

{

P2=0x08;

P0=dispcode[second1];//显示秒的个位

delay(1);

P2=0x04;

P0=dispcode[second10]; //显示秒的十位

delay(1);

P2=0x02;

P0=dispcode[minute1]; //显示分的个位

delay(1);

P2=0x01;

P0=dispcode[minute10];//显示分的十位

delay(1);

}

voiddisplay2(data10,data1,hour10,hour1) //显示第二页天时子程序

//unsignedchardata10,data1,hour10,hour1;

{

P2=0xf8;

P0=dispcode[data1];//显示天的个位

delay(1);

P2=0xf4;

P0=dispcode[data10]; //显示天的十位

delay(1);

P2=0xf2;

P0=dispcode[hour1]; //显示时的个位

delay(1);

P2=0xf1;

P0=dispcode[hour10];//显示时的十位

delay(1);

}

voiddisplay3(year10,year1,month10,month1) //显示第三页年月子程序

//unsignedcharyear10,year1,month10,month1;

{

P2=0xf2;

P0=dispcode[month1];//显示月的个位

delay(1);

P2=0xf1;

P0=dispcode[month10]; //显示月的十位

delay(1);

P2=0xf8;

P0=dispcode[year1]; //显示月的个位

delay(1);

P2=0xf4;

P0=dispcode[year10];//显示月的十位

delay(1);

}

voidmain()

{

unsignedcharflag=0;

Initial_DS1302(); //初始化DS1302这个时钟芯片,

P10=0;//点亮测试灯

while(1)

{

DS1302_GetTime(&time1); //读取时间参数

time[3]=(time1.Second)%10; //把秒的个位数据存入time[3]

time[2]=(time1.Second)/10; //把秒的十位数据存入time[2]

time[1]=(time1.Minute)%10; //把分的个位数据存入time[1]

time[0]=(time1.Minute)/10; //把分的十位数据存入time[0]

date[3]=(time1.Day)%10;

date[2]=(time1.Day)/10;

date[1]=(time1.Hour)%10;

date[0]=(time1.Hour)/10;

year[3]=(time1.Year)%10;

year[2]=(time1.Year)/10;

year[1]=(time1.Month)%10;

year[0]=(time1.Month)/10;

//display1(time[0],time[1],time[2],time[3]);

if(P11==0)

{

delay(50);

if(P11==0)

{

flag++;

if(flag>2)//flag:1显示第二页日时;2显示第三页年月0:显示第一页分秒

{

flag=0;

}

}

while(P11==0);

}

/*if(P1^6==0) //如果按下TimeSet键一下,开始显示日期,再按一下进入日期跟时钟的调节模式

{

delay(50);

if(P1^6==0)

{

flag++;

if(flag>6)

{

flag=0;

}

}

while(P1^6==0);

}*/

switch(flag)

{

case0:display1(time[0],time[1],time[2],time[3]); //调用子函数display,把存入数组time的数据给显示出来

break;

case1:display2(date[0],date[1],date[2],date[3]); //调用子函数display,把存入数组date的数据给显示出来

break;

case2:display3(year[0],year[1],year[2],year[3]);

break;

/* case3:time1.Month=button_date(time1.Month,13,12); //调整月

DS1302_SetTime(0x88,time1.Month);

display(10,10,date[2],date[3]);

break;

case4:time1.Day=button_date(time1.Day,32,31); //调整日

DS1302_SetTime(0x86,time1.Day);

display(10,10,date[4],date[5]);

break;

case5:time1.Minute=button_time(time1.Minute,60,59); //调整分

DS1302_SetTime(0x82,time1.Minute);

display(time[2],time[3],10,10);

break;

case6:time1.Second=button_time(time1.Second,60,59); //调整秒

DS1302_SetTime(0x80,time1.Second);

display(10,10,time[4],time[5]);

break;*/

}

}

}

㈨ 求单片机电子时钟程序设计

#include "../inc/DS1307.H"
#include "../inc/delay.H"
#include "../inc/i2c.H" unsigned char idata Sec,Min,Hr,Dy,Dt,Mn,Yr;
bit hour_mode=0;
/********************************************************************************
函数功能: 数码转换
bcd:BCD码 z:为1转换高位,否则转换低位 Data:二进制数
********************************************************************************/
unsigned char BCD_ASCII(unsigned char bcd,bit z) //把BCD码转换为ASCII码
{
unsigned char temp;
if(z)
temp=(bcd>>4)+'0'; //+48
else temp=(bcd&0x0f)+'0'; //+48
return temp;
}
unsigned char CHAR_BCD(unsigned char Data) //把二进制数转换为BCD码
{
unsigned char bcd; if(Data>100) Data=0;
bcd = Data/10;
bcd<<=4;
bcd = bcd+(Data%10);
return bcd;
}
/********************************************************************************
函数功能: 判断日期是否合法
a:年(00-99之间) b:月 d:日
********************************************************************************/
bit Leap_year(unsigned char n) //判断是否为闰年 计算范围2000-2099年
{
if((((2000+n)%4 == 0)&&((2000+n)%100 != 0)) || ((2000+n)%400 == 0))
return 0;
else return 1; //是闰年返回1
}
bit Valid_date(unsigned char a,unsigned char b,unsigned char c)
{
unsigned char flag=1; if((b<=0)||(b>12)||(c<=0)||(c>31)) flag=0;
if(((b==4)||(b==6)||(b==9)||(b==11))&&(c>30)) flag=0;
if(Leap_year(a)) if((b==2)&&(c>29)) flag=0;
else if(b==2&&c>28) flag=0;
return flag; //合法返回1
}
/********************************************************************************
函数功能: 初始化时间和日期
********************************************************************************/
void RTC_init(void)
{
i2c_start();
i2c_sendbyte(ADDRTC); //写器件地址
i2c_waitACK();
i2c_sendbyte(0); // 地址指针置为 0
i2c_waitACK();
i2c_sendbyte(Sec&0x7f); //CH(Sec^7)位置为 0,启动时钟
i2c_waitACK();
i2c_stop();

i2c_start();
i2c_sendbyte(ADDRTC);
i2c_waitACK();
i2c_sendbyte(2); // 地址指针置为 2
i2c_waitACK();
if(hour_mode)
i2c_sendbyte(Hr|0x40); // 12小时模式,Hr^6置1
else i2c_sendbyte(Hr&0xbf); // 24小时模式,Hr^6置0
i2c_waitACK();
i2c_stop();

i2c_start();
i2c_sendbyte(ADDRTC);
i2c_waitACK();
i2c_sendbyte(7); // 地址指针置为 7
i2c_waitACK();
i2c_sendbyte(0x10); // sqwe引脚1Hz的输出
i2c_waitACK();
i2c_stop();
}
/********************************************************************************
函数功能: 写RTC寄存器
********************************************************************************/
void write_RTC_time(void)
{
i2c_start();
i2c_sendbyte(ADDRTC); // 写从机地址(器件地址)
i2c_waitACK();
i2c_sendbyte(0); // 地址指针置为 0
i2c_waitACK();
i2c_sendbyte(Sec); // Sec
i2c_waitACK();
i2c_sendbyte(Min); // Min
i2c_waitACK();
i2c_sendbyte(Hr); // Hr
i2c_waitACK();
i2c_sendbyte(Dy); // Dy
i2c_waitACK();
i2c_sendbyte(Dt); // Dt
i2c_waitACK();
i2c_sendbyte(Mn); // Mn
i2c_waitACK();
i2c_sendbyte(Yr); // Yr
i2c_waitACK();
i2c_stop();
}/********************************************************************************
********************************************************************************/

㈩ 51单片机简易电子钟设计。汇编语言编写

KEYVALEQU 30H
KEYTMEQU 31H
KEYSCANEQU 32H
DATEQU 33H
SCANLEDEQU 39H
CLKEQU 77H
SECEQU 78H
MINEQU 79H
HOUREQU 7AH
PAUSEBIT 00H
DOTBIT 01H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR;50ms定时
ORG 001BH
LJMP T1ISR;扫描显示
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#11H
MOV TH0,#03CH
MOV TL0,#0B0H
MOV TH1,#0ECH
MOV TL1,#078H
MOV KEYVAL,#0
MOV SCANLED,#0
MOV 33H,#10H
MOV 34H,#10H
MOV 35H,#10H
MOV 36H,#10H
MOV 37H,#10H
MOV 38H,#10H
MOV SEC,#0
MOV MIN,#0
MOV HOUR,#0
MOV CLK,#0
CLR PAUSE
SETB EA
SETB ET1
SETB TR1
LOOP:
LCALL KEYSEL
MOV A,KEYVAL
CJNE A,#0FFH,LOOP1
SJMP LOOP
LOOP1:
CJNE A,#10,LOOP2;“ON”启动
SETB TR0
SETB ET0
SETB PAUSE
SJMP LOOP
LOOP2:
CJNE A,#11,LOOP3;“=”清零
MOV SEC,#0
MOV MIN,#0
MOV HOUR,#0
LCALL DISCHG
SJMP LOOP
LOOP3:
CJNE A,#15,LOOP4;“+”暂停
CLR TR0
CLR ET0
CLR PAUSE
SJMP LOOP
LOOP4:
CJNE A,#14,LOOP5;“-”清显示暂停
MOV 33H,#10H
MOV 34H,#10H
MOV 35H,#10H
MOV 36H,#10H
MOV 37H,#10H
MOV 38H,#10H
CLR TR0
CLR ET0
CLR PAUSE
SJMP LOOP
LOOP5:
CJNE A,#10,LOOP6;数字键
LOOP6:
JC LOOP7
LJMP LOOP
LOOP7:
JNB PAUSE,LOOP8;暂停状态可以输入数字键
LJMP LOOP
LOOP8:
MOV 33H,34H
MOV 34H,35H
MOV 35H,36H
MOV 36H,37H
MOV 37H,38H
MOV 38H,KEYVAL
MOV A,33H
SWAP A
ORL A,34H
LCALL BCDH
MOV HOUR,A
MOV A,35H
SWAP A
ORL A,36H
LCALL BCDH
MOV MIN,A
MOV A,37H
SWAP A
ORL A,38H
LCALL BCDH
MOV SEC,A
LJMP LOOP

;------------------
;BCD转换为十六进制
BCDH:
MOV B,#10H
DIV AB
MOV R7,B
MOV B,#10
MUL AB
ADD A,R7
RET
;------------------
;十六进制转换为BCD
HBCD:
MOV B,#10
DIV AB
SWAP A
ORL A,B
RET
;------------------
KEYSEL:
MOVKEYVAL,#0
MOVKEYSCAN,#0EFH
LCALLGETKEY
MOVA,KEYTM
JZKEYS1
MOVKEYVAL,A
SJMPKEYRTN
KEYS1:
MOVKEYSCAN,#0DFH
LCALLGETKEY
MOVA,KEYTM
JZKEYS2
CLRC
ADDA,#4
MOVKEYVAL,A
SJMPKEYRTN
KEYS2:
MOVKEYSCAN,#0BFH
LCALLGETKEY
MOVA,KEYTM
JZKEYS3
CLRC
ADDA,#8
MOVKEYVAL,A
SJMPKEYRTN
KEYS3:
MOVKEYSCAN,#7FH
LCALLGETKEY
MOVA,KEYTM
JZKEYRTN
CLRC
ADDA,#12
MOVKEYVAL,A
KEYRTN:
LCALL CHGKEY
RET
;--------------------
GETKEY:
MOV KEYTM,#0
MOVA,KEYSCAN
MOVP3,A
NOP
MOVA,P3
ANLA,#0FH
XRLA,#0FH
JZNOKEY
MOV R2,#10
LCALL DELAY
MOVA,P3
ANLA,#0FH
XRLA,#0FH
JZNOKEY
MOVA,P3
ANLA,#0FH
MOVR7,A
SF:
MOVA,P3
ANLA,#0FH
XRLA,#0FH
JNZSF
MOVA,R7
CJNEA,#0EH,NK1
MOVKEYTM,#1
SJMPNOKEY
NK1:
CJNEA,#0DH,NK2
MOVKEYTM,#2
SJMPNOKEY
NK2:
CJNEA,#0BH,NK3
MOVKEYTM,#3
SJMPNOKEY
NK3:
CJNEA,#07H,NOKEY
MOVKEYTM,#4
NOKEY:RET
;--------------------
DELAY:
MOV R3,#50
DELAY1:
MOV R4,#100
DJNZ R4,$
DJNZ R3,DELAY1
DJNZ R2,DELAY
RET
;--------------------
T0ISR:
PUSH ACC
CLR TR0
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0
INC CLK
MOV A,CLK
CJNE A,#20,T0ISRE
MOV CLK,#0
INC SEC
MOV A,SEC
CJNE A,#60,T0ISRE
MOV SEC,#0
INC MIN
MOV A,MIN
CJNE A,#60,T0ISRE
MOV MIN,#0
INC HOUR
MOV A,HOUR
CJNE A,#24,T0ISRE
MOV SEC,#0
MOV MIN,#0
MOV HOUR,#0
T0ISRE:
LCALL DISCHG
POP ACC
RETI
;--------------------
DISCHG:
MOV A,HOUR
LCALL HBCD
PUSH ACC
ANL A,#0FH
MOV 34H,A
POP ACC
ANL A,#0F0H
SWAP A
MOV 33H,A
MOV A,MIN
LCALL HBCD
PUSH ACC
ANL A,#0FH
MOV 36H,A
POP ACC
ANL A,#0F0H
SWAP A
MOV 35H,A
MOV A,SEC
LCALL HBCD
PUSH ACC
ANL A,#0FH
MOV 38H,A
POP ACC
ANL A,#0F0H
SWAP A
MOV 37H,A
RET
;--------------------
T1ISR:
PUSH ACC
CLR TR1
MOV TH1,#0ECH
MOV TL1,#78H
SETB TR1
MOV DPTR,#LEDTAB
T100:
MOV R0,#DAT
MOV A,SCANLED
ADD A,R0
MOV R0,A
MOV A,SCANLED
JNZ T101
MOV P2,#01H
CLR DOT
SJMP T1DIS
T101:
DEC A
JNZ T102
MOV P2,#02H
SETB DOT
SJMP T1DIS
T102:
DEC A
JNZ T103
MOV P2,#04H
CLR DOT
SJMP T1DIS
T103:
DEC A
JNZ T104
MOV P2,#08H
SETB DOT
SJMP T1DIS
T104:
DEC A
JNZ T105
MOV P2,#10H
CLR DOT
SJMP T1DIS
T105:
MOV P2,#20H
CLR DOT
T1DIS:
MOV A,@R0
MOVC A,@A+DPTR
JNB DOT,T1DIS1
ORL A,#01H
T1DIS1:
CPL A
MOV P0,A
INC SCANLED
MOV A,SCANLED
CJNE A,#6,T1END
MOV SCANLED,#0
T1END:
POP ACC
RETI
;--------------------
CHGKEY:
MOV A,KEYVAL
JZ KV16
DEC A
JNZ KV01
MOV KEYVAL,#7
RET
KV01:
DEC A
JNZ KV02
MOV KEYVAL,#4
RET
KV02:
DEC A
JNZ KV03
MOV KEYVAL,#1
RET
KV03:
DEC A
JNZ KV04
MOV KEYVAL,#10
RET
KV04:
DEC A
JNZ KV05
MOV KEYVAL,#8
RET
KV05:
DEC A
JNZ KV06
MOV KEYVAL,#5
RET
KV06:
DEC A
JNZ KV07
MOV KEYVAL,#2
RET
KV07:
DEC A
JNZ KV08
MOV KEYVAL,#0
RET
KV08:
DEC A
JNZ KV09
MOV KEYVAL,#9
RET
KV09:
DEC A
JNZ KV10
MOV KEYVAL,#6
RET
KV10:
DEC A
JNZ KV11
MOV KEYVAL,#3
RET
KV11:
DEC A
JNZ KV12
MOV KEYVAL,#11
RET
KV12:
DEC A
JNZ KV13
MOV KEYVAL,#12
RET
KV13:
DEC A
JNZ KV14
MOV KEYVAL,#13
RET
KV14:
DEC A
JNZ KV15
MOV KEYVAL,#14
RET
KV15:
DEC A
JNZ KV16
MOV KEYVAL,#15
RET
KV16:
MOV KEYVAL,#0FFH
RET
;--------------------
LEDTAB:DB 0FCH;"0"00H
DB 60H;"1"01H
DB 0DAH;"2"02H
DB 0F2H;"3"03H
DB 66H;"4"04H
DB 0B6H;"5"05H
DB 0BEH;"6"06H
DB 0E0H;"7"07H
DB 0FEH;"8"08H
DB 0F6H;"9"09H
DB 0EEH;"A"0AH
DB 3EH;"B"0BH
DB 9CH;"C"0CH
DB 7AH;"D"0DH
DB 9EH;"E"0EH
DB 8EH;"F"0FH
DB 00H;" "10H
;--------------------
END

阅读全文

与基于单片机的简易时钟设计相关的资料

热点内容
安卓手机mp3压缩工具 浏览:214
程序员和交易员 浏览:422
怎么变字体样式app 浏览:173
名字叫汤什么的视频app 浏览:209
金属加密键盘联系电话 浏览:335
自制解压牛奶盒子教程 浏览:64
编译高手的图片 浏览:922
单片机数码管显示时分秒 浏览:780
手指解压最简单的方法 浏览:345
韩国邮箱服务器地址 浏览:967
android版本介绍 浏览:410
pdf文件加密软件 浏览:410
长沙住房app怎么看备案 浏览:603
安装加密软件的电脑会被监控么 浏览:221
java微博源码 浏览:569
堆排序简单实现python 浏览:461
单片机引脚与键盘的关系 浏览:132
压缩火柴盒制作 浏览:38
谷歌地图android偏移 浏览:214
bitlocker硬盘加密空间 浏览:238