(SKU:RB-03T013)RF433Mhz无线收发模块
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(""); } }