Last active
December 19, 2015 05:49
-
-
Save buildcircuit/5907445 to your computer and use it in GitHub Desktop.
315Mhz wireless receiver- experiment 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RECEIVER | |
// Connect data pin to Pin 11 of Arduino | |
#include <VirtualWire.h> // you must download and install the VirtualWire.h to your hardware/libraries folder | |
int numbers[3]; // Change 3 to number of integers you wish to send. | |
void setup() | |
{ | |
Serial.begin(9600); | |
// Initialise the IO and ISR | |
vw_set_ptt_inverted(true); // Required for RX Link Module | |
vw_setup(1000); // Bits per sec | |
//vw_set_rx_pin(2); // We will be receiving on pin 23 (Mega) ie the RX pin from the module connects to this pin. | |
vw_rx_start(); // Start the receiver | |
Serial.println("Receiver ready!"); | |
} | |
void loop() | |
{ | |
uint8_t buf[VW_MAX_MESSAGE_LEN]; | |
uint8_t buflen = VW_MAX_MESSAGE_LEN; | |
if (vw_get_message(buf, &buflen)) // check to see if anything has been received | |
{ | |
Serial.print(buflen, DEC); | |
Serial.println(" bytes received!"); | |
for (int i = 0; i < buflen; i++) | |
{ | |
Serial.print("buf["); | |
Serial.print(i, DEC); | |
Serial.print("]="); | |
Serial.print(buf[i], DEC); | |
Serial.print(" "); | |
} | |
Serial.println(); | |
//memcpy(buf, numbers, buflen); | |
for (int i = 0; i < 3; i++) | |
{ | |
numbers[i] = word(buf[i*2+1], buf[i*2]); | |
Serial.print("numbers["); | |
Serial.print(i, DEC); | |
Serial.print("]="); | |
Serial.print(numbers[i], DEC); | |
Serial.print(" "); | |
} | |
Serial.println(); | |
} | |
delay(50); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment