Hello Everyone,
I am troubling with my megas,first let me explain what I would like to do,I am trying to communicate two megas using NRF24L01 transceiver.I have a joystick module and I am trying to get the position of the joystick via NRF24L01s.Unfortunately it does not work(I always got "No radio available message ").I have used 10 microfarad capacitor(between gnd and vcc pins of nrf24l01) also but nothing changed.By the way my RX led is blinking in the receiver mega but TX led does not blink on the transmitter mega.I hope I've explained well.Can you help me ?
I am using these pinouts for receiver and transmitter for nrf24l01s ;
NRF24L01(Receiver/Transmitter) Joystick
GND -->GND GND->GND
VCC -->3.3V (external) VCC->5V
CE --> 9 Vx->A0
CSN --->53 VY->A1
SCK ---->52
MOSI---->51
MISO--->50
IRQ ---> Free
RECEIVER Sketch
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 53
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int joystick[2];
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() )
{
bool done = false;
while (!done)
{
// Fetching the data payload
done = radio.read( joystick, sizeof(joystick) );
Serial.print("X = ");
Serial.print(joystick[0]);
Serial.print(" Y = ");
Serial.println(joystick[1]);
}
}
else
{
delay(1000);
Serial.println("No radio available");
}
}
Transmitter Sketch
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CSN_PIN 53
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(9, CSN_PIN);
int joystick[2];
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
}
void loop()
{
joystick[0] = analogRead(JOYSTICK_X);
joystick[1] = analogRead(JOYSTICK_Y);
radio.write( joystick, sizeof(joystick) );
}