Using NRF24L01 for multi servo controll

Hello all,

So I have recently started a project using two NRF24L01’s the transmitter is on a Nano and the other is on a Uno with a servo shield and three servos.

I want to use a joystick button on the transmitter to start controlling the three servos. So far i have written code for controlling just one servo and so far it does not work. it compiles fine and I can get it on the nano and uno. But other than that,nothing.

Any help or ideas would be greatly appreciated!

Here is the code for the transmitter:

#include <RF24.h>
#define button 4

RF24 radio(7, 8 ); // CNS, CE
const byte addresses[6] = {“00001”};
boolean buttonState = 0;

void setup() {
pinMode(button , INPUT);
radio.begin();
radio.openWritingPipe(addresses[1]); // 00001
radio.setPALevel(RF24_PA_MIN);
}

void loop() {

delay(3);
radio.stopListening();
buttonState = digitalRead(button);
radio.write(&buttonState, sizeof(buttonState));

}

And here is the code for the receiver:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

Servo servonum1;
Servo servonum2;
Servo servonum3;

int servo1 = 0;
int servo2 = 1;
int servo3 = 2;

int oldButtonState = LOW;

#define button 4
#define SERVOMIN 262
#define SERVOMAX 488

RF24 radio(7, 8 ); // CNS, CE
const byte addresses[6] = {“00001”};

boolean buttonState = 0;

void setup() {
pinMode(12, INPUT);
Serial.begin(9600);
randomSeed(analogRead(0));
pwm.begin();

pwm.setPWMFreq(60);
servonum1.attach(0);
radio.begin();
radio.openReadingPipe(1, addresses[1]); // 00001
radio.setPALevel(RF24_PA_MAX);
}

void loop() {
delay(10);
radio.startListening();
if ( radio.available()) {
while (!radio.available());
radio.read(&buttonState, sizeof(buttonState));

int newButtonState = digitalRead(button);
if (newButtonState == HIGH && oldButtonState == LOW)

if (newButtonState==HIGH)

Serial.println(servo1);
for (uint16_t pulselength = SERVOMIN; pulselength < SERVOMAX; pulselength) {
pwm.setPWM(servo1, 0, pulselength);
}
delay(15);
for (uint16_t pulselength = SERVOMAX; pulselength > SERVOMIN; pulselength) {
pwm.setPWM(servo1, 0, pulselength);
}
delay(15);

servo1 ++;
if (servo1 > 15) servo1 = 0;
}
oldButtonState = newButtonState;
}