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 ;
}
}