⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 da0832.c

📁 DA0832.rar
💻 C
字号:
#include<reg52.h>
#include"delay.h"
#define	uint	unsigned	int
#define	uchar	unsigned	char
#define	Data  P2	
sbit 	csda=P1^0;
sbit 	wr=P1^1;
sbit		LCDrs=P3^5;
sbit		LCDrw=P3^6;
sbit		LCDe=P3^7;
uint out[]={0x00,0x03,0x06,0x09,0x0c,0x10,0x13,0x16,0x19};
uint	temp=0,temp_i=0;
void	delay(uchar	m)
{
	uchar	i,j;
	for(i=0;i<m;i++)
		for(j=0;j<100;j++);

}

/***********************************************
1602的写数据函数
************************************************/
void	LCD_write_data(uchar	date)
{
	LCDrs=0;
	LCDrs=1;
	P0=date;
	delay(5);
	LCDe=1;
	delay(5);	
	LCDe=0;
}
/********************************************************
1602的写命令函数
********************************************************/
void	LCD_write_command(uchar	com)
{
	LCDrs=1;
	LCDrs=0;
	P0=com;
	delay(5);
	LCDe=1;
	delay(5);	
	LCDe=0;
}
/********************************************************
LCD数值转换计算
********************************************************/
void  LCD_data_deal(uint	DT)
{
	uint 	Num;
	Num=DT/10;
	DT%=10;
	LCD_write_data(Num+48);		
	Num=DT;
	LCD_write_data(Num+48);
	LCD_write_command(0x80);
	delay_nms(2);

}
/********************************************************
LCD启动初始化函数
********************************************************/
void	LCD_init()
{
	LCDrw=0;
	LCDe=0;
	LCD_write_command(0x38);
	LCD_write_command(0x0c);
	LCD_write_command(0x06);
//	LCD_write_comment(0x01);
	LCD_write_command(0x80);
}
/********************************************************
外部中断初始化INT0  INT1
********************************************************/
void	Int0_init()
{
	IT0=1;
	IE0=1;
	EX0=1;
	EA=1;
}
void	Int1_init()
{
	IT1=1;
	IE1=1;
	EX1=1;
	EA=1;
}
void	main()
{
	
	uchar	m;
	LCD_init();
	Int0_init();
	Int1_init();
	while(1)
	{
	csda=0;
	wr=0;
	Data=out[temp];
	LCD_write_command(0x80);
	LCD_data_deal(temp);
	delay(3);
	wr=1;	
	
	}

}

/********************************************************
外部中断用来按键加一
********************************************************/

void	Int0()	interrupt	0
{
	temp_i=temp;
	temp_i++;
	temp=temp_i;
	delay_nms(10);


}
/********************************************************
外部中断用来按键减一
********************************************************/
void	Int1()	interrupt	2
{
	uint	temp_n=temp;
	temp_n--;
	temp=temp_n;
	delay_nms(10);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -