Wireless communication with Arduino and NRF24L01 2.4GHz module

im having an error in my code, i have uploaded the code for receiver and transmitter below with the error, can anyone help me to deal with the error?

HAVING ERROR IN VOID LOOP - expected ')' before numeric constant

receiver will receive the number 1 moves the servo counter-clockwise , with the number 2 moves the servo clockwise and the number 3 (L character typed ), Activates the led.

// Program: NRF24L01 Receiver - Servo motor 
// Author: Arduino and Co.

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

// Store the data received 
int received [ 1 ];

// Initializes the NRF24L01 pins 9 (EC) and 53 (CS) Arduino Mega 
RF24 radio ( 9 , 53 );

Servo myservo;

// Set the address for communication between the modules 
const  uint64_t pipe = 0xE13CBAF433LL ;

// Set the LED pin 
int LED1 = 5 ;

void setup ()
{
  // Servo connected to pin 4 
  myservo.attach ( 4 );
  // Set the LED pin as output
  pinMode (LED1, OUTPUT);
  // Initialize the serial 
  Serial.begin ( 57600 );
  // Initialize communication of NRF24L01
  radio.begin ();
  // Goes into reception mode 
  radio.openReadingPipe ( 1 , pipe);
  radio.startListening ();
  // Initial message 
  Serial.println ( "Waiting for data ..." );
}

void loop ()
{
  // Check radio signal 
  if (radio.available ())
  {
    bool done;
      done = radio.read (received 1); <=====ERROR
      Serial.print ( "Received:" );    
      Serial.print (received [ 0 ]);
      
      // If you received one, move the servo to the left 
      if (received [ 0 ] == 1 )
      {
        delay ( 10 );
        Serial.println ( "-> Turning motor to the left" );
        myservo.write ( 1 );
      }
      
      // If received 2 moves the servo to the right 
      if (received [ 0 ] == 2 )
      {
        delay ( 10 );
        Serial.println ( "-> Turning motor to the right" );
        myservo.write ( 160 );
      }

      // If received 3, the LED lights 
      if (received [ 0 ] == 3 )
      {
        delay ( 10 );
        Serial.println ( "-> Lights LED" );
        DigitalWrite (LED1, HIGH);
      }
      Else
      {
        DigitalWrite (LED1, LOW);
      }
      delay ( 100 );
    }
  }
}

===========================================================
HAVING ERROR IN LAST IF STATEMENT - expected ')' before numeric constant

Open the serial monitor you can send the characters 1, 2 or L to the receiver:

// Program: NRF24L01 Issuer - Servo motor 
// Author: Arduino and Co.

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

// Store the character typed serial 
char value [ 1 ];

// Store the data sent 
int data [ 1 ];

// Initializes the NRF24L01 pins 9 (EC) and 10 (CS) Arduino One 
RF24 radio ( 8 , 9 );

// Set the address for communication between the modules 
const  uint64_t pipe = 0xE13CBAF433LL ;

void setup ()
{
  // Initialize the serial 
  Serial.begin ( 57600 );
  Serial.println ( "Type 1, 2 or L and press SEND ..." );
  
  // Initialize communication of NRF24L01
  radio.begin ();
  // Enters transmission mode
  radio.openWritingPipe (pipe);
}

void loop ()
{
  // Le character typed in serial 
  if (Serial.available ()> 0 )
  {
    value [ 0 ] = Serial.read ();
  }
  
  // Send via 1 radio if you enter the value 1 
  if (value [ 0 ] == '1' )
  {
    Serial.println ( "Sent: 1 - Gira servant to the left" );
    data [ 0 ] = 1 ;
    radio.write (data 1 );
    delay ( 100 );
    value [ 0 ] = 0 ;
  }
  
  // Send 2 via radio if you enter the value 2 
  if (value [ 0 ] == '2' )
  {
    Serial.println ( "Sent: 2 - Turns servant to the right" );
    data [ 0 ] = 2 ;
    radio.write (data 1 );
    delay ( 100 );
    value [ 0 ] = 0 ;
  }
  
  // Send 3 via radio if typed the L character 
  if (value [ 0 ] == 'L' )
  {
    Serial.println ( "Sent: L - Turns the LED" );
    data [ 0 ] = 3 ;
   radio.write (data 1 );  <======ERROR
    delay ( 100 );
    value [ 0 ] = 0 ;
  }
}

done = radio.read (received 1);

should be

done = radio.read (received [1]);

The second error is a similar issue.

SamIAm93:
done = radio.read (received 1);

should be

done = radio.read (received [1]);

Rubbish.

You could try

      done = radio.read (received, 2);

   radio.write (data, 2);

Better use a 2 here because you want to transfer ints, which have 2 bytes on standard Arduinos.

SamIAm93:
done = radio.read (received 1);

should be

done = radio.read (received [1]);

Given int received [ 1 ]; your suggestion is just silly.

Whandall:
Rubbish.

You could try

      done = radio.read (received, 2);

radio.write (data, 2);




Better use a 2 here because you want to transfer ints, which have 2 bytes on standard Arduinos.

i have tried done = radio.read (received, 2); but its error again it says :
exit status 1
void value not ignored as it ought to be

void value not ignored

Massive clue

So you copied an example that does not match the library you are using.

Just drop done (and its definition).

radio.read (received, 2);

Maybe have a look at this Simple nRF24L01+ Tutorial

I believe it works.

...R

Woah, I must have been sleep deprived,my apologies.

I would only add that it's generally better to do it like

radio.read (received, sizeof(received) );

If you happen to change the payload size in future you won't have to change all the read and write calls

SamIAm93:
I would only add that it's generally better to do it like

radio.read (received, sizeof(received) );

Generally, it's best not to make generalisations like that.
What if "received" is an argument of the function you're in?

hey thanks for ur suggestions out there.
ok i have dropped the bool declaration from
bool done;
done = radio.read (received 1)

to radio.read(recevied,1) and has compiled without error but now the problem is that the receiver is not receiving the data. the pipe is the same on both but its not receiving.

Post the corrected code - we're not psychic

// Program: NRF24L01 Receiver - Servo motor
// Author: Arduino and Co.

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

// Store the data received
int received [ 1 ];

// Initializes the NRF24L01 pins 9 (EC) and 53 (CS) Arduino Mega
RF24 radio ( 9 , 53 );

Servo myservo;

// Set the address for communication between the modules
const uint64_t pipe = 0xE13CBAF433LL ;

// Set the LED pin
int LED1 = 5 ;

void setup ()
{
// Servo connected to pin 4
myservo.attach ( 4 );
// Set the LED pin as output
pinMode (LED1, OUTPUT);
// Initialize the serial
Serial.begin ( 57600 );
// Initialize communication of NRF24L01
radio.begin ();
// Goes into reception mode
radio.openReadingPipe ( 1 , pipe);
radio.startListening ();
// Initial message
Serial.println ( "Waiting for data ..." );
}

void loop ()
{
// Check radio signal
if (radio.available ())
{

radio.read (received, 1);
Serial.print ( "Received:" );
Serial.print (received [ 0 ]);

// If you received one, move the servo to the left
if (received [ 0 ] == 1 )
{
delay ( 10 );
Serial.println ( "-> Turning motor to the left" );
myservo.write ( 1 );
}

// If received 2 moves the servo to the right
if (received [ 0 ] == 2 )
{
delay ( 10 );
Serial.println ( "-> Turning motor to the right" );
myservo.write ( 160 );
}

// If received 3, the LED lights
if (received [ 0 ] == 3 )
{
delay ( 10 );
Serial.println ( "-> Lights LED" );
DigitalWrite (LED1, HIGH);
}
Else
{
DigitalWrite (LED1, LOW);
}
delay ( 100 );
}
}
}

====================================================

// Program: NRF24L01 Transmitter - Servo motor
// Author: Arduino and Co.

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

// Store the character typed serial
char value [ 1 ];

// Store the data sent
int data [ 1 ];

// Initializes the NRF24L01 pins 9 (EC) and 10 (CS) Arduino One
RF24 radio ( 8 , 9 );

// Set the address for communication between the modules
const uint64_t pipe = 0xE13CBAF433LL ;

void setup ()
{
// Initialize the serial
Serial.begin ( 57600 );
Serial.println ( "Type 1, 2 or L and press SEND ..." );

// Initialize communication of NRF24L01
radio.begin ();
// Enters transmission mode
radio.openWritingPipe (pipe);
}

void loop ()
{
// Le character typed in serial
if (Serial.available ()> 0 )
{
value [ 0 ] = Serial.read ();
}

// Send via 1 radio if you enter the value 1
if (value [ 0 ] == '1' )
{
Serial.println ( "Sent: 1 - Gira servant to the left" );
data [ 0 ] = 1 ;
radio.write (data, 1 );
delay ( 100 );
value [ 0 ] = 0 ;
}

// Send 2 via radio if you enter the value 2
if (value [ 0 ] == '2' )
{
Serial.println ( "Sent: 2 - Turns servant to the right" );
data [ 0 ] = 2 ;
radio.write (data, 1 );
delay ( 100 );
value [ 0 ] = 0 ;
}

// Send 3 via radio if typed the L character
if (value [ 0 ] == 'L' )
{
Serial.println ( "Sent: L - Turns the LED" );
data [ 0 ] = 3 ;
radio.write (data, 1 );
delay ( 100 );
value [ 0 ] = 0 ;
}
}

{facepalm - be careful what you wish for} With code tags, please.