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

📄 main.c

📁 这是一个红外接受的主函数
💻 C
字号:
//************************************************************
//*程序名称	: 按键流水灯测试程序(带按键软件去抖)
//*硬件环境	: MJ51学习板
//*CPU类型	: AT89S52@12MHz
//*程序作者	:  LittleJimmy, jimmy416@163.com
//*编写日期	:  2007-8-28
//************************************************************

//============================================================
//*特别说明: 学习板中LED/数码管与LCD电路复用了P0口,此试验中使
//*用了LCD作为显示,所以请将J3中低七位跳线跳至LCD一侧
//============================================================
//============================================================
//*特别说明: 学习板中外部中断引脚和DS18B20,红外接收共用P3。2
//*引脚,所以使用红外接收时,请不要同时使用DS18B20测温功能和
//*外部中断1功能
//============================================================
#include <reg52.h>
#include <stdio.h>
#include <intrins.h>
#include "1602.h"
#include "IrDrv.h"

sbit BEEP = P3^6;
int beepcount = 0;


//****************************************************************
//* 蜂鸣器控制函数
//****************************************************************
void beepprocess(void){
	if(beepcount >= 1000){
		BEEP = 1;
		beepcount = 1000;
	}
	else{
		beepcount++;
		BEEP = 0;
	}
}


//****************************************************************
//* 主函数
//****************************************************************
void main(){
	unsigned char temp;
	char disparray[16];

	LCD_init();
	LcdClr();
	LCD_bglight(1);
	IrInit();
	LcdPrint(0,0,"MJ51 Board");
	LcdPrint(0,1,"Please Enter...");

	while(1){
		if(temp=GetIrValue()){
			beepcount = 0;
			sprintf(disparray,"IR Value: %02d    \0",(int)(256-temp));
			LcdPrint(0,1,disparray);
		}
		beepprocess();
	}

}

⌨️ 快捷键说明

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