RF 2.4 GHz nRF24L01 Proggramming Error ?

Hi,

I'm trying to use nrf24l01 rf 2.4 ghz module.

I find a prepeared code. Which is:

/* YourDuinoStarter Example: nRF24L01 Receive Joystick values
 - WHAT IT DOES: Receives data from another transceiver with
   2 Analog values from a Joystick or 2 Potentiometers
   Displays received values on Serial Monitor
 - SEE the comments after "//" on each line below
 - CONNECTIONS: nRF24L01 Modules See:
 http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 9
   4 - CSN to Arduino pin 10
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED
   
 - V1.00 11/26/13
   Based on examples at http://www.bajdi.com/
   Questions: terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int joystick[2];  // 2 element array holding Joystick readings
void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  delay(1000);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();;
}//--(end setup )---
void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if ( radio.available() )
  {
    // Read the data payload until we've received everything
    bool done = false;
    while (!done)
    {
      // Fetch the data payload
      done = radio.read( joystick, sizeof(joystick) );
      Serial.print("X = ");
      Serial.print(joystick[0]);
      Serial.print(" Y = ");      
      Serial.println(joystick[1]);
    }
  }
  else
  {    
      Serial.println("No radio available");
  }
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
//NONE
//*********( THE END )***********

However it gives an error at receiver side arduino mega 2560 when i was compiling.

Which is:

receiver.ino: In function 'void loop()':

receiver.ino:51:12: error: void value not ignored as it ought to be

Error compiling.

I cant find the solution. In the internet, some guys struggle with the same problem however, no one find the solution.

Can you help me please?

receiver.ino:51:12: error: void value not ignored as it ought to be

Which is line 51?

      done = radio.read( joystick, sizeof(joystick) );

Why do you assume that the read() method returns a value? The error message is telling you that it does not.

We've had this exact same question before.

michinyon:
We've had this exact same question before.

can you solved this ?

PaulS:
Which is line 51?

      done = radio.read( joystick, sizeof(joystick) );

Why do you assume that the read() method returns a value? The error message is telling you that it does not.

my friend made that by using that code. i use same code same circuit, but it doesnt work. i think its about arduino ide version. i updated it to 1.6.5. every sample codes on internet has this row.

done = radio.read( joystick, sizeof(joystick) );

If you are using a mega, make you define the correct SPI pins.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).

Always check the source ( GitHub repository ) .
There are sample codes there for RF24 and you can verify to see if you are using read method correctly, for example passing correct parameters.( Very few "libraries" methods bother to check for validity of passed parameters )
If you are really using the RF24 class , read method does return value ( true / false) AS IT SHOULD when hardware is involved.
The compiler reports error not necessary pointing you in right direction to solve it , but at this point it has very little to do how SPI is implemented , connected.

Voo-doo advises can be misleading and debugging hardware when compiler is reporting software error unnecessarily complicates things.

Your code compiles for me without error which suggests that you aren't using the same version of the RF24 library as was used by the code sample.
The read function in my installed RF24 library returns a boolean value:

bool RF24::read( void* buf, uint8_t len )
{
  // Fetch the payload
  read_payload( buf, len );

  // was this the last of the data available?
  return read_register(FIFO_STATUS) & _BV(RX_EMPTY);
}

The RF24.cpp has this in the first comment:

Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

Check to see if your version is newer, or older, than that.

Pete