Arduino驱动315MHZ无线模块
Sapere Aude, quia Veritas Vos Liberabit.
敢于知道,因为真理使我们自由。
准备工具
1、两个Adruino开发板
2、315M发射、接收模块
3、杜邦线若干(面包板可选)
4、电脑一台(有两个USB接口)
PS:如果距离相对较远的话别忘了外接天线
Arduino接线
开发板(Arduino发射) | 发射模块 |
---|---|
VCC | VCC |
GND | GND |
10 | data |
开发板(Arduino接收) | 接收模块 |
---|---|
VCC | VCC |
GND | GND |
2 | data |
RC-Switch库引入
点击直接穿越
打开连接直接下载zip版本的,然后在Arduino引入库
发射模块代码
/*Example for different sending methodshttps://github.com/sui77/rc-switch/*/#include <RCSwitch.h>RCSwitch mySwitch = RCSwitch();void setup() {Serial.begin(9600);// Transmitter is connected to Arduino Pin #10 mySwitch.enableTransmit(10);// Optional set protocol (default is 1, will work for most outlets)// mySwitch.setProtocol(2);// Optional set pulse length.// mySwitch.setPulseLength(320);// Optional set number of transmission repetitions.// mySwitch.setRepeatTransmit(15);}void loop() {/* Same switch as above, but using decimal code */mySwitch.send(1, 24);delay(2000); mySwitch.send(2, 24);delay(2000);// /* See Example: TypeA_WithDIPSwitches */
// mySwitch.switchOn("11111", "00010");
// delay(1000);
// mySwitch.switchOff("11111", "00010");
// delay(1000);// /* Same switch as above, but using binary code */
// mySwitch.send("000000000001010100010001");
// delay(1000);
// mySwitch.send("000000000001010100010100");
// delay(1000);// /* Same switch as above, but tri-state code */
// mySwitch.sendTriState("00000FFF0F0F");
// delay(1000);
// mySwitch.sendTriState("00000FFF0FF0");
// delay(1000);// delay(20000);
}
在一个窗口粘贴好代码, 设置接收Arduino的端口,编译并上传
接收模块代码
/*Simple example for receivinghttps://github.com/sui77/rc-switch/
*/#include <RCSwitch.h>RCSwitch mySwitch = RCSwitch();void setup() {Serial.begin(9600);mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
}void loop() {if (mySwitch.available()) {Serial.print("Received ");Serial.println( mySwitch.getReceivedValue() );
// Serial.print(" / ");
// Serial.print( mySwitch.getReceivedBitlength() );
// Serial.print("bit ");
// Serial.print("Protocol: ");
// Serial.println( mySwitch.getReceivedProtocol() );delay(1500);mySwitch.resetAvailable();}
}
新创建一个窗口粘贴接收代码,设置端口,编译并上传
打开接收板的串口监视器观察接收数据
预期接收数据1和2交替循环
效果展示
实物图
Arduino驱动315MHZ无线模块相关推荐
- STC8H开发(十五): GPIO驱动Ci24R1无线模块
目录 STC8H开发(一): 在Keil5中配置和使用FwLib_STC8封装库(图文详解) STC8H开发(二): 在Linux VSCode中配置和使用FwLib_STC8封装库(图文详解) ST ...
- 使用Arduino实现JDY-40无线模块的通信
1.用Arduino对JDY-40无线模块的参数设置 将如下代码烧录至Arduino开发板中: void setup() {Serial.begin(9600);pinMode(3,OUTPUT);/ ...
- Arduino UNO + 433无线模块实例
Arduino UNO + 433无线模块实例 发射和接收接线示意图 发送端代码:(Arduino + 433超外差发射机 高,低电平和悬空三种模式切换) /*This is a minimal sk ...
- STC8H开发(十六): GPIO驱动XL2400无线模块
目录 STC8H开发(一): 在Keil5中配置和使用FwLib_STC8封装库(图文详解) STC8H开发(二): 在Linux VSCode中配置和使用FwLib_STC8封装库(图文详解) ST ...
- arduino驱动LD3320语音识别模块
LD3320: LD3320 是一颗基于非特定人语音识别(SI-ASR:Speaker-Independent Automatic SpeechRecognition)技术的语音识别/声控芯片.提供 ...
- Arduino驱动HC-05蓝牙模块
HC-05模块概述 HC-05是一个蓝牙模块,连接到微控制器的串行端口,允许微控制器通过蓝牙连接与其他设备通信.模块本身可以在主模式和从模式下运行,并且可以用于各种应用,例如,智能家居应用,远程控制, ...
- ROS 之 arduino 驱动 超声波测距模块
US-015是目前市场上分辨率最高,重复测量一致性最好的超声波测距模块:US-015的分辨率高于1mm,可达0.5mm,测距精度高:重复测量一致性好,测距稳定可靠.US-015超声波测距模块可实现2c ...
- cc1101初始化c语言程序,STC89C52单片机驱动CC1101无线模块的发送C语言程序
#include #define INT8U unsigned char #define INT16 Uunsigned int #define WRITE_BURST 0x40//连续写入 #def ...
- cc1101初始化c语言程序,STC89C52单片机驱动CC1101无线模块的接收C语言程序
#include #include #defineINT8Uunsigned char #defineINT16Uunsigned int #define WRITE_BURST 0x40//连续写入 ...
- Arduino - 驱动HC-SR501 人体红外感应模块
参考文章: Arduino - 驱动HC-SR501 人体红外感应模块 Arduino 使用人体红外感应模块 HC-SR501 代码如下: /* Arduino 驱动HC-SR501 人体红外感应模块 ...
最新文章
- (C++)string 的两种输入方式和输出方式
- 失业后跑摩的985高校硕士,被质疑学历、深“扒”论文...
- R语言一次性读入多个csv文件实战:一次导入多个csv形成一个统一的dataframe、原生R方法、readr包、data.table
- sql,nolock
- 【Android 异步操作】Handler 机制 ( Android 提供的 Handler 源码解析 | Handler 构造与消息分发 | MessageQueue 消息队列相关方法 )
- android配置文件说明
- 在Qt 中如何使用OpenCV库
- raspberry pi_书评:“ Raspberry Pi for Secret Agents”的使用效果不佳
- 解决utf8编码的php生成csv打开乱码的问题
- 函数命名空间,函数的名字
- 计算机主板的接口结构名称10,[pc玩家]主板接口大盘点,细数历年主流的主板接口:内部接口...
- 《Monkey Android》第15课Spinner和AutoCompleteTextView
- Python 飞机航班案例分析
- 正月十五闹元宵,平安吉祥乐团圆
- ARM处理器比较:A8/A9
- 【论文笔记_自蒸馏_2020】Regularizing Class-wise Predictions via Self-knowledge Distillation
- 【OpenCV3图像处理】颜色空间转换(一)颜色空间分类总结
- iphone上安装android系统,如何在iPhone上安装Android操作系统?
- IT行业常用网站与平台汇总(持续更新...)
- HTML基础学习笔记(1)