From bd123f688c3566dd1413e3ec17f6b5a7134cf2cb Mon Sep 17 00:00:00 2001 From: Andrea Manni Date: Thu, 26 Mar 2015 18:09:22 +0100 Subject: [PATCH] RF string --- hardware/rf315_433/string_rx/string_rx.ino | 37 ++++++++++++++++++++++ hardware/rf315_433/string_tx/string_tx.ino | 24 ++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 hardware/rf315_433/string_rx/string_rx.ino create mode 100644 hardware/rf315_433/string_tx/string_tx.ino diff --git a/hardware/rf315_433/string_rx/string_rx.ino b/hardware/rf315_433/string_rx/string_rx.ino new file mode 100644 index 0000000..a40ba28 --- /dev/null +++ b/hardware/rf315_433/string_rx/string_rx.ino @@ -0,0 +1,37 @@ +/* String RX + +Send a string with a XD-RF-5V +- https://mashenarduinoprojects.wordpress.com/projects/arduino-315330433mhz-transmitterreceiver-xd-fstxd-rf-5v/ +*/ + +#include + // recive +void setup() +{ + Serial.begin(9600); // Configure the serial connection to the computer + vw_set_ptt_inverted(true); // Required by the RF module + vw_setup(2000); // bps connection speed + vw_set_rx_pin(3); // Arduino pin to connect the receiver data pin + vw_rx_start(); // Start the receiver + Serial.print("Reciver engaged"); +} + +void loop() +{ + + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + if (vw_get_message(buf, &buflen)) // We check if we have received data + { + int i; + // Message with proper check + for (i = 0; i < buflen; i++) + { + Serial.write(buf[i]); // The received data is stored in the buffer + // and sent through the serial port to the computer + } + Serial.println(); + + } +} + diff --git a/hardware/rf315_433/string_tx/string_tx.ino b/hardware/rf315_433/string_tx/string_tx.ino new file mode 100644 index 0000000..90bcefc --- /dev/null +++ b/hardware/rf315_433/string_tx/string_tx.ino @@ -0,0 +1,24 @@ +/* String RX + +Send a string with a XD-RF-5V +- https://mashenarduinoprojects.wordpress.com/projects/arduino-315330433mhz-transmitterreceiver-xd-fstxd-rf-5v/ +*/ + +#include +//send +void setup() +{ + vw_set_ptt_inverted(true); // Required by the RF module + vw_setup(2000); // bps connection speed + vw_set_tx_pin(10); // Arduino pin to connect the receiver data pin +} + +void loop() +{ + //Message to send: + const char *msg = "This is cool"; + vw_send((uint8_t *)msg, strlen(msg)); + + vw_wait_tx(); // We wait to finish sending the message + delay(200); // We wait to send the message again +} -- 2.39.2