I have a Mega Pro and rf24 radios. So I connected a rf24 to my Mega Pro according to the pin usage in your code and loaded your code. I made a couple changes to your code. I put the printing of the incoming data inside of the if radio available if block so that printing only happens if there is radio data and made the sender send every 1 second instead of continuously. I use an Uno as a sender. I am able to duplicate what you are seeing. If I include the AccelStepper library without creating any AccelStepper objects the code works fine. Construct even one instance of a stepper and it no longer receives data. I do not know why.
So then I took one of my rf24 test programs and modified the receive code to work on the Mega Pro. I use an Uno to send data. I included your Accelstepper code into my know to work test receiver code and it works fine. I do not know why it works with my code and not yours. Just for information, here is my code. It is derived from code from Robin2's simple rf24 tutorial.
Transmit code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const byte CE_PIN = 9;
const byte CSN_PIN = 10;
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
struct LdrValues
{
int ldr_1;
int ldr_2;
}ldrValues;
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
const byte LDR1 = A0;
const byte LDR2 = A1;
void setup()
{
Serial.begin(115200);
Serial.println("SimpleTx Starting");
pinMode(LDR1, INPUT_PULLUP);
pinMode(LDR2, INPUT_PULLUP);
radio.begin();
radio.setChannel(76); //76 library default
//RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
radio.setPALevel(RF24_PA_HIGH);
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3, 5); // delay, count
radio.openWritingPipe(slaveAddress);
}
void loop()
{
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis)
{
send();
Serial.print("LDR 1 = ");
Serial.print(ldrValues.ldr_1);
Serial.print(" LDR 2 = ");
Serial.println(ldrValues.ldr_2);
prevMillis = millis();
}
}
//====================
void send()
{
ldrValues.ldr_1 = analogRead(LDR1);
ldrValues.ldr_2 = analogRead(LDR2);
radio.write( &ldrValues, sizeof(ldrValues) );
}
Receive code:
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <AccelStepper.h>
const int stepPin = 12;
const int dirPin = 14;
const int stepPin1 = 10;
const int dirPin1 = 8;
int del;
int motorSpeed1;
int motorSpeed2;
//
//Stepper motors setup
AccelStepper leftWheel(1, stepPin, dirPin);
AccelStepper rightWheel(1, stepPin1, dirPin1);
const byte CE_PIN = 53;
const byte CSN_PIN = 49;
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
struct LdrValues
{
int ldr_1;
int ldr_2;
} ldrValues;
bool newData = false;
//===========
void setup()
{
Serial.begin(115200);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setChannel(76); //76 library default
//RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
radio.setPALevel(RF24_PA_HIGH);
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop()
{
getData();
showData();
}
//==============
void getData()
{
if ( radio.available() )
{
radio.read( &ldrValues, sizeof(ldrValues) );
newData = true;
}
}
void showData()
{
if (newData == true)
{
Serial.print("Data received >> ");
Serial.print("LDR 1 = ");
Serial.print(ldrValues.ldr_1);
Serial.print(" LDR 2 = ");
Serial.println(ldrValues.ldr_2);
newData = false;
}
}