Changing this code to control 4 Servo Motors

I wanted to control 4 Servos by using this code which only allows me to control only one servo by potentiometer through NRF24L01 Module. But I am Having Trouble in Modifying the array of these codes. Can Any one Help me Please. These are the codes:

Transmit_2.ino (3.88 KB)

Recive2.ino (1.83 KB)

Please post your code.

These are the codes

Transmitter-Code.ino (872 Bytes)

Receiver-Code.ino (1.38 KB)

No, post your code.

In code tags.

In code tags, as is fully documented in the sticky post at the top of each forum on this board.
How to use this forum - please read

How About This:-

/*
---- Transmitter Code ----
Mert Arduino Tutorial & Projects (YouTube)
Please Subscribe for Support
*/

#include <SPI.h> //the communication interface with the modem
#include "RF24.h" //the library which helps us to control the radio modem

int msg[1];

RF24 radio(8,10); //5 and 10 are a digital pin numbers to which signals CE and CSN are connected.

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem, that will receive data from Arduino.

void setup(void){
radio.begin(); //it activates the modem.
radio.openWritingPipe(pipe); //sets the address of the receiver to which the program will send data.
}

void loop(void){
msg[0] = map (analogRead(0), 0, 1023, 0, 179);
radio.write(msg, 1);
}


/*
---- Receiver Code ----
Mert Arduino Tutorial & Projects (YouTube)
Please Subscribe for Support
*/

#include <Servo.h> //the library which helps us to control the servo motor
#include <SPI.h> //the communication interface with the modem
#include "RF24.h" //the library which helps us to control the radio modem

Servo myServo; //define the servo name

RF24 radio(8,10); /This object represents a modem connected to the Arduino.
Arguments 5 and 10 are a digital pin numbers to which signals
CE and CSN are connected.
/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.

int msg[1];

void setup(){
myServo.attach(3); //3 is a digital pin to which servo signal connected.
radio.begin(); //it activates the modem.
radio.openReadingPipe(1, pipe); //determines the address of our modem which receive data.
radio.startListening(); //enable receiving data via modem
}

void loop(){
if(radio.available()){ //checks whether any data have arrived at the address of the modem
bool done = false; //returns a “true” value if we received some data, or “false” if no data.
while (!done) {
done = radio.read(msg, 1);
myServo.write(msg[0]);
}
}
}

Great.
Apart from the lack of [code][/code] tags.

Yes, another read through the post on how to use this forum will help you with the code tags.

I also want to ask about your goal and the results of your current code.

Results of current code first.

Does your current code work? Are you able to able to move your joystick and see the one servo move?

Goal next.

What do you want to happen? You mention 4 servos. Do you want them to all move the same, moving in response to the one joystick? Or are you also going to add multiple joysticks?

No they are potentiometers.

Yes This code works fine but it is made for only one servo motor control by potentiometer through nrf24l01.

my goal is to modify this code to control 4 servo motors(separately through their potentiometers) with same code methord.

tell me if you are unable to run this code.

I am unable to run this code.

cht-mon its easy peasy to post code in code tags.

#include <Servo.h>    //the library which helps us to control the servo motor
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem

Servo myServo;        //define the servo name
Servo myOtherServo;        //define the other servo's servo name

RF24 radio(8,10);     /*This object represents a modem connected to the Arduino.
                      Arguments 5 and 10 are a digital pin numbers to which signals
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.

int msg[1];

void setup(){
  myServo.attach(3);                //3 is a digital pin to which servo signal connected.
myOtherServo.attach(1987);    //1987 is a digital pin to which servo signal connected.
  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();           //enable receiving data via modem
  }

void loop(){
  if(radio.available()){            //checks whether any data have arrived at the address of the modem
    bool done = false;              //returns a "true" value if we received some data, or "false" if no data.
    while (!done) {
      done = radio.read(msg, 1);
      myServo.write(msg[0]);
      myServo.write( TheOtherMessage[2510]);
    }
  }
}

not tested.

Listen if the code is not compiling it means you have different nrf library please install the nrf library from maniacbug and remove or delete your previous one.i am posting it too here.

The code is compiling, I just can't run it because I don't have your hardware.

It doesn't look like a very difficult problem - what have you tried?

i have tried to, From the transmission side, create an array of messages to send, and then on the receiver end interpret which one it was:

int msg[5]; // 5 elements

but I don't know what to do on receiver end