当前位置:网站首页>基于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
边栏推荐
- Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
- Generate random numbers with high quality and Gaussian distribution
- 自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
- Detailed explanation of Niuke - Gloves
- Installing labellmg tutorial in Windows
- [registration] tf54: engineer growth map and excellent R & D organization building
- Shell脚本——Shell编程规范及变量
- [problem solving] [show2012] random tree
- ClickHouse-表引擎
- Getting started with JDBC
猜你喜欢
Net standard
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
Change the password after installing MySQL in Linux
STM32__ 03 - beginner timer
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
Detailed explanation of Niuke - Gloves
Getting started with JDBC
Mock test using postman
随机推荐
How vscode compares the similarities and differences between two files
Paging SQL
Read a blog, re understand closures and tidy up
Shell脚本——Shell编程规范及变量
【题解】[SHOI2012] 随机树
About stream flow, write it down briefly------
Copy constructor shallow copy and deep copy
线性代数感悟之2
快时钟同步慢时钟域下的异步控制信号slow clk to fast clk
Baidu Map 3D rotation and tilt angle adjustment
Introduction to new functions of camtasia2022 software
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
1-2 characteristics of nodejs
El date picker limits the selection range from the current time to two months ago
Use between nodejs modules
Deep understanding of control inversion and dependency injection
【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明
AIOT产业技术全景结构-数字化架构设计(8)
ASP. Net core dependency injection service life cycle
ClickHouse-SQL 操作