sparkfun RFM69HCW Hook-Up Manual page 16

Table of Contents

Advertisement

// Set up the indicator LED (optional):
pinMode(LED,OUTPUT);
digitalWrite(LED,LOW);
pinMode(GND,OUTPUT);
digitalWrite(GND,LOW);
// Initialize the RFM69HCW:
  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower(); // Always use this for RFM69HCW
// Turn on encryption if desired:
if (ENCRYPT)
    radio.encrypt(ENCRYPTKEY);
void loop()
// Set up a "buffer" for characters that we'll send:
static char sendbuffer[62];
static int sendlength = 0;
// SENDING
// In this section, we'll gather serial characters and
// send them to the other node if we (1) get a carriage retu
rn,
// or (2) the buffer is full (61 characters).
// If there is any serial input, add it to the buffer:
if (Serial.available() > 0)
  { 
char input = Serial.read();
if (input != '\r') // not a carriage return
    { 
      sendbuffer[sendlength] = input;
      sendlength++;
    } 
// If the input is a carriage return, or the buffer is ful
l:
if ((input == '\r') || (sendlength == 61)) // CR or buffe
r full
    { 
// Send the packet!
      Serial.print("sending to node ");
      Serial.print(TONODEID, DEC);
      Serial.print(", message [");
for (byte i = 0; i < sendlength; i++)
        Serial.print(sendbuffer[i]);
      Serial.println("]");
// There are two ways to send packets. If you want
// acknowledgements, use sendWithRetry():
if (USEACK)
      { 
Page 16 of 19

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the RFM69HCW and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Com-13909

Table of Contents