当前位置:网站首页>基于51单片机红外无线通讯仿真
基于51单片机红外无线通讯仿真
2022-04-23 17:07:00 【Xiao~小艳】
目录
资料下载地址:基于51单片机红外无线通信仿真
一、项目功能
该项目分为主机和从机,主机采集温度和光照强度通过IRLINK红外无线发射器传送给从机,并在在12864液晶屏幕上显示出来。
二、仿真
温度83、无亮度
温度65、有亮度
三、程序
部分程序
#include <REG51.h>
#include <intrins.h>
#include "hongwaifashe.h"
void hongwaifashe(void)
{
TMOD = 0x01; //T0 16位工作方式
IR=1; //发射端口常态为高电平
ZZ(setdata[0]);
ZZ(setdata[1]);
}
void ZZ(uchar x)
{
TT0(1,m9); //高电平9mS
TT0(0,m4_5); //低电平4.5mS
/*┈ 发送4帧数据 ┈*/
Z0(SBM);
Z0(~SBM);
Z0(x);
Z0(~x);
/*┈┈ 结束码 ┈┈*/
TT0(1,m_56);
TT0(0,m40);
}/*┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
函数功能:单帧发送程序
入口参数:1帧数据
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈*/
void Z0(uchar temp)
{
uchar v;
for (v=0;v<8;v++) //循环8次移位
{
TT0(1,m_56); //高电平0.65mS
if(temp&0x01) TT0(0,m1_68); //发送最低位
else TT0(0,m_56);
temp >>= 1; //右移一位
}
}
/*┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
函数功能:38KHz脉冲发射 + 延时程序
入口参数:(是否发射脉冲,延时约 x (uS))
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈*/
void TT0(bit BT,uint x)
{
TH0 = x>>8; //输入T0初始值
TL0 = x;
TF0=0; //清0
TR0=1; //启动定时器0
if(BT == 0) while(!TF0); //BT=0时不发射38KHz脉冲只延时;BT=1发射38KHz脉冲且延时;
else while(1) //38KHz脉冲,占空比5:26
{
IR = 0;
if(TF0)break;
if(TF0)break;
IR = 1;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
if(TF0)break;
}
TR0=0; //关闭定时器0
TF0=0; //标志位溢出则清0
IR =1; //脉冲停止后,发射端口常态为高电平
}
版权声明
本文为[Xiao~小艳]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_35654286/article/details/124360345
边栏推荐
猜你喜欢
Scope and scope chain in JS
Document operation II (5000 word summary)
[PROJECT] small hat takeout (8)
Go language, array, string, slice
STM32__03—初识定时器
Sub database and sub table & shardingsphere
Grpc gateway based on Ocelot
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
Signalr can actively send data from the server to the client
随机推荐
Regular filtering of Intranet addresses and segments
线性代数感悟之1
freeCodeCamp----prob_ Calculator exercise
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
[PROJECT] small hat takeout (8)
How much do you know about the process of the interview
CentOS MySQL multi instance deployment
Error in v-on handler: "typeerror: cannot read property 'resetfields' of undefined"
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
Nifi fast installation and file synchronization
SQL database
The new MySQL table has a self increasing ID of 20 bits. The reason is
Calculate pie chart percentage
MySQL restores data through binlog file
手写事件发布订阅框架
. net cross platform principle (Part I)
Handwritten event publish subscribe framework
Some problems encountered in recent programming 2021 / 9 / 8
MySQL master-slave configuration under CentOS
ASP. Net core configuration options (Part 1)