Author Topic: RF24 "GettingStarted" and "led_remote" example tweaks  (Read 2936 times)

tkbay

  • Newbie
  • *
  • Posts: 2
RF24 "GettingStarted" and "led_remote" example tweaks
« on: February 01, 2014, 07:41:47 pm »
FYI, I had to tweak two of the RF24 example programs
to get them to work correctly:

In "GettingStarted",  the program defaults to "role_pong_back"
(receive and echo) mode, but the radio.openReadingPipe() is
set up for the "role_ping_out" mode.

To get the default role and pipe to match up you can change this:

Code: [Select]
  //if ( role == role_ping_out )
  {
    //radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
  }
  //else
  {
    //radio.openWritingPipe(pipes[1]);
    //radio.openReadingPipe(1,pipes[0]);
  }


to this:

Code: [Select]
  //if ( role == role_ping_out )
  {
    //radio.openWritingPipe(pipes[0]);
   // radio.openReadingPipe(1,pipes[1]);
  }
  //else
  {
    //radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1,pipes[0]);
  }



In "led_remote", I had to wrap the radio.write() call
inside radio.stopListening() and radio.startListening() calls
for any of the sent messages (except occasionally the first one)
to get through to the receiving unit:

Code: [Select]
      p("Now sending...");

      radio.stopListening();
      bool ok = radio.write( button_states, num_button_pins );
      radio.startListening();

      if (ok)