Arduino wireless communication projects code example

Example 1: arduino wireless communication

void loop()
{
    // Create our message
    const char *msg = "Hello World";
 
    // Send our message
    radio.send((uint8_t*)msg, strlen(msg));
 
    // Wait until the data has been sent
    radio.waitPacketSent();
 
    // Delay since we dont want to send a trillion packets 
    delay(1000);
 
    // Also inform the serial port that we are done!
    Serial.println("Data Sent");
}

Example 2: arduino wireless communication

void loop()
{
  // Create a 32 byte char buffer
  uint8_t receive_buffer[32];
  uint8_t buflen = sizeof(receive_buffer);
 
  // If data is available, print it
  if (radio.recv(receive_buffer, &buflen))
  {
    Serial.print("Message: ");
    Serial.println((char*)receive_buffer);         
  }
}

Tags:

Html Example