Go Down

Topic: joystick control 4 servos or more to hold position using NRF24l01 (Read 457 times) previous topic - next topic


hi all

im new to arduino programing. i have robotic arm use 4 servo control by joystick. it work fine. but i want to change control it via NRFL2401. how to modivication this code to make code for transmitter and receiver.

im trying to combine it from many code from tutorial control servos via NRF24L01 but always failed.
many tutorial like from youtube or instructables.com is the servo comeback to the start position (not suitable for robotic arm)

this is the code:

//code by Robin2

#include <Servo.h>

#define mainArm 0
#define jib 1
#define bucket 2
#define slew 3

Servo servo[4];

byte angle[4] = {90, 90, 90, 90};
byte potPin[4] = {A0, A1, A2, A3};
byte servoPin[4] = {5, 4, 3, 2};

void setup() {
  Serial.println("Starting DiggerCode.ino");
  for (byte n = 0; n < 4; n++) {

void loop() {

void readJoystick() {
  int potVal;
  for (byte n = 0; n < 4; n++) {
    potVal = analogRead(potPin[n]);
    if (potVal < 450) {
      angle[n] += 1;
      if (angle[n] > 170) {
        angle[n] = 170;
    if (potVal > 570) {
      angle[n] -= 1;
      if (angle[n] < 10) {
        angle[n] = 10;


void moveServos() {
  for (byte n = 0; n < 4; n++) {


You have code that collects joystick positions. You have code to move servos.

Some of the code belongs on the device with the joysticks and a radio. Some of that code belongs on the device with the servos and a radio. The ONLY challenge is determining how to format the data to send and how to use what was sent.

Suppose that you are holding the controller, and your best bud is moving the servos. What do you need to tell him? Or her? Once you've figured that out, formatting the data is easy, after you've decided on text vs. binary.

Once you've figured that out, using the data is pretty simple.

If you have problems, let us know what they are, and what decisions you've made.
The art of getting good answers lies in asking good questions.


The web is full of tutorials on the subject.
Google some up, get your 2 arduinos hooked up with the NRFL2401 and see if you can make them talk to each other.

They try to put it in to your code.

This was the first hit when I googled it.  A pot on one side and a servo on the other.  Looks like it is right up your alley!

Note that they show the servo powered from the arduino 5v pin.  Don't do that.  Separate power for servos with grounds connected is the right way.


Hi PaulS and vinceherman.. thank for advice. Now my problem is solved. I made it.


hi kholbar_gokil, i want to make robot arm but i have your problem. please send me your document as arduino code and other map.  please send to amin.zareasl@gmail.com

Go Up