1void loop()
2{
3 // Create our message
4 const char *msg = "Hello World";
5
6 // Send our message
7 radio.send((uint8_t*)msg, strlen(msg));
8
9 // Wait until the data has been sent
10 radio.waitPacketSent();
11
12 // Delay since we dont want to send a trillion packets
13 delay(1000);
14
15 // Also inform the serial port that we are done!
16 Serial.println("Data Sent");
17}
1RH_ASK radio(2000, 11, 12);
2
3void setup()
4{
5 Serial.begin(9600); // Use this for debugging
6
7 // Speed of 2000 bits per second
8 // Use pin 11 for reception
9 // Use pin 12 for transmission
10
11 if (!radio.init())
12 {
13 Serial.println("Radio module failed to initialize");
14 }
15}
1void loop()
2{
3 // Create a 32 byte char buffer
4 uint8_t receive_buffer[32];
5 uint8_t buflen = sizeof(receive_buffer);
6
7 // If data is available, print it
8 if (radio.recv(receive_buffer, &buflen))
9 {
10 Serial.print("Message: ");
11 Serial.println((char*)receive_buffer);
12 }
13}
1#include <RH_ASK.h> // Include the RH_ASK library
2#include <SPI.h> // Not actually used but needed to compile the RH_ASK library