Adding accessories to arduino pro mini

G'DAY

i have built 2 transceivers that work, i would like to add an LED to one and a BUZZER to the other,
i need to program them so when they receive a msg the accessories actvate, LED lights up when msg received and BUZZER sounds when the other receives the msg.

i have searched for hrs and tried to add and remove sketches for days

what code do i add.
any help would be greatly appreciated

my coding is as follows

#include <SPI.h>
#include "RF24.h"

char msg[27] = "Hello Nathan How Are You!";
char rec[27];
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
RF24 radio(9, 10);

void setup() 
  // put your setup code here, to run once:
{
Serial.begin(115200);
radio.begin();
radio.enableAckPayload();
radio.enableDynamicPayloads();
radio.setRetries(15, 15);

radio.openWritingPipe(pipe[0]);
}

void loop()
{
  Serial.println("TX MILLS: " + String(millis()));
  
  if (radio.write(msg, sizeof(msg)))
{


Serial.print("TX: ");
Serial.println( msg );
if (radio.isAckPayloadAvailable())
{
  radio.read(&rec, 27);
  Serial.print("RX: ");
  Serial.println(rec);
}
else
{
  Serial.println("No ACK Received...");
}
}
else
{

  Serial.println("Cannot Transmit...");
}

delay(1000);
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

I note that you have only posted a single sketch rather than two, one for the transmitter and one for the receiver

sorry. the other unit is this 


#include <SPI.h>
#include "RF24.h"


char msg[27] = "Im Well Thank You !";
char rec[27];
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
RF24 radio(9,10);


void setup() 
  // put your setup code here, to run once:
{
  Serial.begin(115200);
  radio.begin();
  radio.enableAckPayload();
  radio.enableDynamicPayloads();
  radio.setRetries(15, 15);
  

  radio.openReadingPipe(1, pipe[0]);
  radio.startListening();
  
  }
  
void loop()
{ 
Serial.println("RX MILLIS: " + String(millis()));

if (radio.available())
{
  radio.read(&rec, sizeof(rec));
  Serial.print("RX: ");
  Serial.println(rec);
  radio.writeAckPayload(1, msg, sizeof(msg));
  Serial.print("TX: ");
  Serial.println(msg);
  
}
delay(500);
}

Still without code tags I see

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.