Here is tested code to read a pot, transmit the reading via rf24, receive the reading and send the reading to a servo. This code has been tested on Unos. This code uses example code from Robin2's simple rf24 tutorial.
Is this what you want?
Transmit
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const byte CE_PIN = 9;
const byte CSN_PIN = 10;
const byte potPin = A0;
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
struct Payload
{
int potValue;
}payload;
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 200; // send 5 times per second
void setup()
{
Serial.begin(115200);
Serial.println("SimpleTx 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.setRetries(3, 5); // delay, count
radio.openWritingPipe(slaveAddress);
}
void loop()
{
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis)
{
send();
Serial.print("pot value = ");
Serial.println( payload.potValue);
prevMillis = millis();
}
}
//====================
void send()
{
payload.potValue = analogRead(potPin);
radio.write( &payload, sizeof(payload) );
}
Receive
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
const byte servoPin = 4;
const byte CE_PIN = 9;
const byte CSN_PIN = 10;
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
Servo servo;
struct Payload
{
int potValue;
} payload;
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();
servo.attach(servoPin);
}
//=============
void loop()
{
getData();
showData();
actOnData();
}
//==============
void getData()
{
if ( radio.available() )
{
radio.read( &payload, sizeof(payload) );
newData = true;
}
}
void showData()
{
if (newData == true)
{
Serial.print("Data received >> ");
Serial.print("pot value = ");
Serial.println( payload.potValue);
//newData = false;
}
}
void actOnData()
{
servo.write(map(payload.potValue, 0, 1023, 10, 170));
newData = false;
}