hello my name is angelos and i am working on a project with nrf24l01 transmitter the problem is i have to touch the ce pin and then send once the packege and stops i have too touch again the ce to send the next value any idea ?
here is the code :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int forward_backward=A0;
int left_right=A1;
int brake=A2;
int joystick[3];
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
radio.setRetries(15, 15);
}
void loop()
{
joystick[0] = analogRead(forward_backward);
joystick[1] = analogRead(left_right);
joystick[2] =analogRead(brake);
joystick[0] = map(joystick[0], 0, 1023, 0, 255);
joystick[1] = map(joystick[1], 0, 1023, 0, 255);
joystick[2] = map(joystick[2], 0, 1023, 0, 255);
radio.write(joystick, sizeof(joystick) );
Serial.println(joystick[0]);
delay(1000);
Serial.println(joystick[1]);
delay(1000);
Serial.println(joystick[2]);
delay(1000);
Serial.println("hahahah");
delay(1000);
}
here is the received code :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int joystick[3];
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();;
}
void loop()
{
if ( radio.available() )
{
// Read the data payload until we've received everything
bool done = false;
while (!done)
{
done=radio.read(joystick, sizeof(joystick) );
Serial.print("forward_backward_value = ");
Serial.print(joystick[0]);
delay(1000);
Serial.print(" left_right_value = ");
Serial.println(joystick[1]);
delay(1000);
Serial.print(" brake_value = ");
Serial.println(joystick[2]);
delay(1000);
}
}
else
{
Serial.println("No radio available");
}
}