51单片机学习笔记——秒表实现

实现简单秒表,按键控制秒表的开始、暂停与重置。#include "reg52.h"typedef unsigned int u16;typedef unsigned char u8;#define led P0sbit k3=P3^2;sbit k4=P3^3;sbit LSA=P2^2;sbit LSB=P2^3;sbit LSC=P2^4;u8 LED[]={0x...
摘要由CSDN通过智能技术生成

实现简单秒表,按键控制秒表的开始、暂停与重置。

#include "reg52.h"

typedef unsigned int u16;
typedef unsigned char u8;
#define led P0

sbit k3=P3^2;
sbit k4=P3^3;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;

u8 LED[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
			0x7f,0x6f,0x40};

u8 L[8][3]={
  {1,1,1},{0,1,1},{1,0,1},{0,0,1},{1,1,0},{0,1,0},{1,0,0},{0,0,0}};

static u8 hour =0;
static u8 min=0;
static u8 s=0;

char Sh(char lo)
{
	switch(lo)
	{
		case 0:return hour/10;
		case 1:return hour%10;	 
		case 2:return 10;	 
		case 3:return min/10;  
		case 4:return min%10;  
		case 5:return 10;	 
		case 6:return s/10;	  
		case 7:return s%10;  
	}
}

void Initial()
{
	TMOD=TMOD||0x01;
	TH0=0xfc;
	TL0=0x18;
	ET0=1;
	IT0=1;
	EX0=1;
	IT1=1;
	EX1=1;
	TR0=1;
    EA=1;
}

void delay(u16 i)
{
	while(i--);
}

void main()
{
	Initial();
	while(1)
	{
	   u8 i=0;
	   for(i=0;i<8;i+&#
  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值