(SKU:RB-03T013)RF433Mhz无线收发模块

315/433 RF无线模块详解



http://www.alsrobot.cn/wiki/index.php?title=(SKU:RB-03T013)RF433Mhz%E6%97%A0%E7%BA%BF%E6%94%B6%E5%8F%91%E6%A8%A1%E5%9D%97






例子程序

程序编译前需要进行库文件的加载,点此下载RF433Mhz无线收发模块使用的库文件。

transmitter module
#include <VirtualWire.h>
//Grove - 315(433) RF link kit Demo v1.0
//connect the sent module to D2 to use  
#include <VirtualWire.h>
int RF_TX_PIN = 2;
void setup()
{
  vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
  vw_setup(2000); // Transmission speed in bits per second.
} 
void loop()
{
  const char *msg = "hello";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'hello' every 400ms.
  delay(400); 
}




receiver module
//Grove - 315(433) RF link kit Demo v1.0
//connect the receive module to D2 to use ..
#include <VirtualWire.h>
int RF_RX_PIN = 2; 
void setup()
{
  Serial.begin(9600);
  Serial.println("setup");
  vw_set_rx_pin(RF_RX_PIN);  // Setup receive pin.
  vw_setup(2000); // Transmission speed in bits per second.
  vw_rx_start(); // Start the PLL receiver.
}
 
void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if(vw_get_message(buf, &buflen)) // non-blocking I/O
  {
    int i;
    // Message with a good checksum received, dump HEX
    Serial.print("Got: ");
    for(i = 0; i < buflen; ++i)
    {
      Serial.print(buf[i], HEX);
      Serial.print(" ");
	  //Serial.print(buf[i]);
    }
    Serial.println("");
  }
}

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值