当前位置:网站首页>基于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
边栏推荐
- STM32__ 03 - beginner timer
- 手写事件发布订阅框架
- [pimf] openharmony paper Club - what is the experience of wandering in ACM survey
- JS, entries(), keys(), values(), some(), object Assign() traversal array usage
- vscode如何比较两个文件的异同
- . net cross platform principle (Part I)
- 自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
- Use between nodejs modules
- [markdown notes]
- Shell-sort命令的使用
猜你喜欢
Sub database and sub table & shardingsphere
Rtklib 2.4.3 source code Notes
Milvus 2.0 détails du système d'assurance de la qualité
Scope and scope chain in JS
Milvus 2.0 質量保障系統詳解
Lock lock
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
Detailed explanation of the penetration of network security in the shooting range
VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
随机推荐
Shell-入门、变量、以及基本的语法
ASP. Net core reads the configuration file in the class library project
El cascade and El select click elsewhere to make the drop-down box disappear
Interface document yaml
ASP. NET CORE3. 1. Solution to login failure after identity registers users
Aiot industrial technology panoramic structure - Digital Architecture Design (8)
The new MySQL table has a self increasing ID of 20 bits. The reason is
【解决报错】Error in v-on handler: “TypeError: Cannot read property ‘resetFields’ of undefined”
BUG_ me
Tencent resolves the address according to the IP address
Preliminary understanding of promse
Paging SQL
Lock lock
Quick install mongodb
正则过滤内网地址和网段
拷贝构造函数 浅拷贝与深拷贝
ASP. Net core dependency injection service life cycle
Shell脚本——Shell编程规范及变量
如何用Redis实现分布式锁?
Nacos + aspnetcore + Ocelot actual combat code