您的位置 首页 资料

51单片机+315M无线射频模块承受程序

用的就是那种最普通的最便宜的大约几块钱的315兆的无线模块接受发射,不带解码的,433m的程序也是一样的不用修改压缩包中的内容:上

用的便是那种最一般的 最廉价的 大约几块钱 的315兆的无线模块承受发射,不带解码的,433m的程序也是相同的不必修正

压缩包中的内容:


上位机以及完好程序在文件夹中,我们可自己下载
地址是:http://www.51hei.com/bbs/dpj-19033-1.html

下面是承受端的源代码:
#include
#include “string.h”

//液晶块
#define LCM_RW P3_6 //界说引脚
#define LCM_RS P3_5
#define LCM_E P3_7
#define LCM_Data P1
#define Busy 0x80 //用于检测LCM状况字中的Busy标识
typedef int byte;
typedef unsigned int word;

void Read_Temp(void);
void mychar(char,char);

void WriteDataLCM(unsigned char WDLCM);
void WriteCommandLCM(unsigned char WCLCM,BuysC);
unsigned char ReadDataLCM(void);
unsigned char ReadStatusLCM(void);
void LCMInit(void);
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData);
void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData);
void Delay5Ms(void);
void Delay400Ms(void);

void delay(word useconds)
{
for(;useconds>0;useconds–);
}

void mychar(char xx,char yy)
{

DisplayOneChar(0,0,0×54);
DisplayOneChar(1,0,0×65);
DisplayOneChar(2,0,0x6D);
DisplayOneChar(3,0,0×70);
DisplayOneChar(4,0,0×65);
DisplayOneChar(5,0,0×72);
DisplayOneChar(6,0,0×61);
DisplayOneChar(7,0,0×74);
DisplayOneChar(8,0,0×75);
DisplayOneChar(9,0,0×72);
DisplayOneChar(10,0,0×65);
DisplayOneChar(11,0,0x3A);
///////////////////////自界说字符
WriteCommandLCM(0x48, 0); //榜首行
WriteDataLCM(0x06);
WriteCommandLCM(0x49, 0); //第2行
WriteDataLCM(0x09);
WriteCommandLCM(0x4a, 0); //第3
WriteDataLCM(0x09);
WriteCommandLCM(0x4b, 0); //第4
WriteDataLCM(0x06);
WriteCommandLCM(0x4c, 0); //第5
WriteDataLCM(0x00);
WriteCommandLCM(0x4d, 0); //第6
WriteDataLCM(0x00);
WriteCommandLCM(0x4e, 0); //第7
WriteDataLCM(0x00);
WriteCommandLCM(0x4f, 0); //第8
WriteDataLCM(0x00);
DisplayOneChar(xx,yy,0x01);
DisplayOneChar(xx+1,yy,0x43);
}
//写数据
void WriteDataLCM(unsigned char WDLCM)
{
ReadStatusLCM(); //检测忙
LCM_Data = WDLCM;
LCM_RS = 1;
LCM_RW = 0;
LCM_E = 0; //若晶振速度太高能够在这后加小的延时
LCM_E = 0; //延时
LCM_E = 1;
}

//写指令
void WriteCommandLCM(unsigned char WCLCM,BuysC) //BuysC为0时疏忽忙检测
{
if (BuysC) ReadStatusLCM(); //根据需要检测忙
LCM_Data = WCLCM;
LCM_RS = 0;
LCM_RW = 0;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
}

//读状况
unsigned char ReadStatusLCM(void)
{
LCM_Data = 0xFF;
LCM_RS = 0;
LCM_RW = 1;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
while (LCM_Data & Busy); //检测忙信号
return(LCM_Data);
}

void LCMInit(void) //LCM初始化
{
LCM_Data = 0;
WriteCommandLCM(0x38,0); //三次显现形式设置,不检测忙信号
Delay5Ms();
WriteCommandLCM(0x38,0);
Delay5Ms();
WriteCommandLCM(0x38,0);
Delay5Ms();

WriteCommandLCM(0x38,1); //显现形式设置,开端要求每次检测忙信号
WriteCommandLCM(0x08,1); //封闭显现
WriteCommandLCM(0x01,1); //显现清屏
WriteCommandLCM(0x06,1); // 显现光标移动设置
WriteCommandLCM(0x0C,1); // 显现开及光标设置
}

//按指定方位显现一个字符
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
{
Y &= 0x1;
X &= 0xF; //约束X不能大于15,Y不能大于1
if (Y) X |= 0x40; //当要显现第二行时地址码+0x40;
X |= 0x80; //算出指令码
WriteCommandLCM(X, 0); //这儿不检测忙信号,发送地址码
WriteDataLCM(DData);
}

//按指定方位显现一串字符 ***本来的遇到空格0x20就不显现***
void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData)
{
unsigned char ListLength,j;
ListLength = strlen(DData);
Y &= 0x1;
X &= 0xF; //约束X不能大于15,Y不能大于1
if (X <= 0xF) //X坐标应小于0xF
{
for(j=0;j {
DisplayOneChar(X, Y, DData[j]); //显现单个字符
X++;
}
}
}

//5ms延时
void Delay5Ms(void)
{
unsigned int TempCyc = 5552;
while(TempCyc–);
}

//400ms延时
void Delay400Ms(void)
{
unsigned char TempCycA = 5;
unsigned int TempCycB;
while(TempCycA–)
{
TempCycB=7269;
while(TempCycB–);
};
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ziliao/318058.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部