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

📄 clock.c

📁 AT89C51的温度采集报警系统..可串口与PC通信
💻 C
字号:
#include<reg52.h>
#include"lcd1602.h"
#include"ds18b20.h"
#include"ds18b20_2.h"
#include"ds18b20_3.h"
#include"ds18b20_4.h"
#define uchar unsigned char 
#define uint unsigned int
#define TIMER0_COUNT 0xEE11
sbit SPK=P3^5;
sbit LED1=P3^6;
sbit LED2=P3^7;
bit flag;
  uint wendu;
  uint wendu1;
  uint wendu2;
    uint wendu3;
uchar count,timer0_tick,count=0;
static void timer0_initialize(void)   
 {
     EA=0;             
     timer0_tick=0;
     TR0=0;               
     TMOD=0X01;         
     TL0=(TIMER0_COUNT & 0X00FF);   
     TH0=(TIMER0_COUNT >> 8);     
     PT1=1;              
     ET0=1;           
     TR0=1;            
     EA=1;          
 }
void display_temp()
{

  uchar A1,A2;
  uchar A3,A4;
  uchar A5,A6;
  uchar A7,A8;

  tmpchange(); 
  wendu=tmp();
  A1=wendu/10;
  A2=wendu%10;
  gotoxy(1,1);
  display_data(A1);
  display_string(".");
  write_date(int_to_char[A2]); 
  
  
  tmpchange2();
  wendu1=tmp2();
  A3=wendu1/10;
  A4=wendu1%10;
  gotoxy(2,1);
  display_data(A3);
  display_string(".");
  write_date(int_to_char[A4]);

  tmpchange3();
  wendu2=tmp3();
  A5=wendu2/10;
  A6=wendu2%10;
  gotoxy(1,7);
  display_data(A5);
  display_string(".");
  write_date(int_to_char[A6]);

  tmpchange4(); 
  wendu3=tmp4();
  A7=wendu3/10;
  A8=wendu3%10;
  gotoxy(2,7);
  display_data(A7);
  display_string(".");
  write_date(int_to_char[A8]); 
  
}







 


void timer0(void) interrupt 1
{
     TR0=0;
     TL0=(TIMER0_COUNT & 0X00FF);//设置Timer0低八位数值
     TH0=(TIMER0_COUNT >> 8);//设置Timer0高八位数值
     TR0=1;
	count++;
     if(count==10) display_temp();


 }

	 

void main()
{
	init_lcd();
    timer0_initialize(); 
     gotoxy(1,1);
     display_string("00.0C");
	   gotoxy(2,1);
	        display_string("00.0C");
			while(1) 
			{
			if((wendu>500) || (wendu1>500) || (wendu2>500) || (wendu3>500))
   			{
   			
   				SPK=~SPK;
			    LED1=~LED1;
   				
				delay(30);
			
   			}
			else  if ((wendu<100) || (wendu1<100) || (wendu2<100) ||  (wendu3<100))
			{
			SPK=~SPK;
			delay(20);
			LED2=~LED2;
			}
			}

	  }
		

⌨️ 快捷键说明

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