当前位置:网站首页>基于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
边栏推荐
- VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN
- Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
- Detailed explanation of Niuke - Gloves
- 文件操作《二》(5000字总结篇)
- [C#] 彻底搞明白深拷贝
- 【WPF绑定3】 ListView基础绑定和数据模板绑定
- Lock锁
- 【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明
- Detailed explanation of Milvus 2.0 quality assurance system
- 网络安全之渗透靶场实战详解
猜你喜欢
Solution architect's small bag - 5 types of architecture diagrams
Smart doc + Torna generate interface document
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
文件操作《二》(5000字总结篇)
Idea of batch manufacturing test data, with source code
VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
. net type transfer
Signalr can actively send data from the server to the client
[PROJECT] small hat takeout (8)
Mock test using postman
随机推荐
Further optimize Baidu map data visualization
[PROJECT] small hat takeout (8)
◰ GL shader handler encapsulation
Devexpress GridView add select all columns
Shell-cut命令的使用
Error in v-on handler: "typeerror: cannot read property 'resetfields' of undefined"
正则过滤内网地址和网段
Shell-awk命令的使用
Deep understanding of control inversion and dependency injection
MySQL restores data through binlog file
Baidu Map Case - Zoom component, map scale component
Paging SQL
【WPF绑定3】 ListView基础绑定和数据模板绑定
ClickHouse-数据类型
1-3 nodejs installation list configuration and project environment
Promise (III)
ClickHouse-SQL 操作
VsCode-Go
ASP. Net core reads the configuration file in the class library project
Promise (I)