51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx

上传人:b****6 文档编号:20528243 上传时间:2023-01-23 格式:DOCX 页数:21 大小:17.07KB
下载 相关 举报
51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx_第1页
第1页 / 共21页
51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx_第2页
第2页 / 共21页
51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx_第3页
第3页 / 共21页
51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx_第4页
第4页 / 共21页
51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx

《51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx(21页珍藏版)》请在冰豆网上搜索。

51单片机流水灯数码管定时器秒表计算器程序Word格式文档下载.docx

temp=~temp;

P1=temp;

temp>

>

=1;

delay(1000);

voidmove_left_only(void){

temp=0x01;

temp<

<

voidmove_right_hlod(void){

temp=0x7f;

for(a=8;

temp=temp>

1;

voidmove_left_hold(void){

temp=0xfe;

voidmain()

{

while

(1)

move_left_hold();

move_mid_side();

move_right_hlod();

move_left_only();

move_right_only();

数码管#include<

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

//0~9

chardata_wei[]={0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0x00};

//0xff全关,之后为第

一个数码管到第八个数码管

//chardata_wei_add[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};

for(j=0;

j<

100;

j++);

voidshow_number_only(void)

inti;

P2=data_wei[1];

//P2为位选

for(i=0;

i<

10;

i++){

P0=data_duan[i];

//P0为段选

/*******************数码管动态显示子程序***************/

voidmove_show1(void)

for(i=1;

2;

P2=data_wei[i];

delay

(1);

voidmove_show2(void)

3;

voidmove_show3(void)

4;

voidmove_show4(void)

5;

voidmove_show5(void)

6;

voidmove_show6(void)

voidmove_show7(void)

8;

voidmove_show8(void)

9;

/********数码管动态显示,实现数码管由1~8在八个数码管上一次显示************/

voidmove_show_hold(void)

inttemp,i;

temp=1000;

for(i=temp;

i--)

move_show1();

temp=600;

move_show2();

temp=400;

move_show3();

temp=200;

move_show4();

move_show5();

move_show6();

temp=100;

move_show7();

move_show8();

voidshow_all(void)//将所有的位选端口打开,变化段选,显示整体变化1~9

P2=data_wei[9];

intmain(void){

while

(1){

//show_number_only();

//move_show_hold();

//show_all();

独立按键

#include<

sbitkey1=P3^0;

sbitd2=P1^0;

inttemp,number=0;

j--);

d2=1;

key1=1;

if(key1==0){

delay(100);

number++;

if(number<

=7){

temp=temp<

else{

number=0;

矩阵按键#include<

chardata_duan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x80,0xc6,

0xc0,0x86,0x8e,};

//0~9chardata_wei[]={0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0x00};

intnumber=0;

//voidmove_show1(void)

//{

//inti;

//for(i=1;

i++){//P2=data_wei[i];

//P0=data_duan[i];

//delay

(1);

//}

//}

//voidmove_show2(void)

//P0=data_duan[i];

voidscan_key(void)

inttemp;

P1=0xfe;

temp=P1;

temp=temp&

0xf0;

while(temp!

=0xf0){

switch(temp){

case0xe0:

number=12;

break;

case0xd0:

number=13;

case0xb0:

number=14;

case0x70:

number=15;

P1=0xfd;

number=8;

number=9;

number=10;

number=11;

P1=0xfb;

number=4;

number=5;

number=6;

number=7;

P1=0xf7;

number=1;

number=2;

number=3;

//returnnumber;

intmain(void)

//intnum=0;

//num=scan_key(num);

scan_key();

P0=data_duan[number];

定时器中断#include<

intnumber=0,time=0;

//TMOD=0x01;

//设置工作方式定时器0

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

//给计数器装初值//TL0=(65535-50000)%256;

//EA=1;

//开总中断//ET0=1;

//定时器T0中断允许//TR0=1;

//启动定时器0

TMOD=0x10;

//设置工作方式定时器1

TH1=(65536-50000)/256;

//给计数器装初值

TL1=(65535-50000)%256;

EA=1;

//开总中断

ET1=1;

//定时器T1中断允许

TR1=1;

//启动定时器1

if(number==20){

P2=data_wei[2];

P0=data_duan[4];

if(time==40){

P2=data_wei[0];

time=0;

voidexter3()interrupt3

time++;

//voidexter1()interrupt1

//time++;

//number++;

时钟#include<

unsignedlongintsecond=0,minute=0,hour=0,point=0,tip=0;

unsignedlonginttime=0,sign=0,number=0,key=0,variable=0;

unsignedlongintS1=0,S2=0,M1=0,M2=0,H1=0;

H2=0;

voidkey_scan(void)

//应用按键检测

//P1=0xfb;

//temp=P1;

//temp=temp&

//while(temp!

=0xf0){//delay

(1);

=0xf0){//switch(temp){//case0xe0:

//case0xd0:

//case0xb0:

//case0x70:

//}

//while(temp!

=0xf0){//temp=P1;

////

voidadjust_alarm(void){

if(number==1){//控制时钟的启动与停止

key=!

key;

if(key==1){

EA=0;

variable=time;

if(key==0){

if(number==2){//调节时间选择标志位

tip=tip+1;

tip=tip%6;

if(tip==0){

tip=6;

if((number==3)&

&

(EA==0)){

if(tip==1)

time=time-1;

if(tip==2)

time=time-10;

if(tip==3)

time=time-60;

if(tip==4)

time=time-600;

if(tip==5)

time=time-3600;

if(tip==6)

time=time-36000;

if((number==4)&

time=time+1;

time=time+10;

time=time+60;

time=time+600;

time=time+3600;

time=time+36000;

//if((number==5)&

(EA==0)){//if(tip==1)

//variable=variable-1;

//if(tip==2)

//variable=variable-10;

//if(tip==3)

//variable=variable-60;

//if(tip==4)

//variable=variable-600;

//if(tip==5)

//variable=variable-3600;

//if(tip==6)

//number=0;

//if((number==6)&

//variable=variable+1;

//variable=variable+10;

//variable=variable+60;

//variable=variable+600;

//variable=variable+3600;

//variable=variable+36000;

voidcompare_time(void)

if(time>

variable){

;

voidalarm_show_s(void)

intsign2;

for(sign2=1;

sign2<

sign2++){//数码管动态显示

S1=second%10;

P2=data_wei[sign2];

P0=data_duan[S1];

for(sign2=2;

sign2++){

S2=second/10;

P0=data_duan[S2];

for(sign2=3;

P0=0xbf;

for(sign2=4;

M1=minute%10;

P0=data_duan[M1];

for(sign2=5;

M2=minute/10;

P0=data_duan[M2];

for(sign2=6;

P2=data_wei

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1