quadcopter +pwm Problem

:confused: Hi everyone

I designed a code if I sent the value of the joystick1 via nrf24l10 being received in another Arduino
output in one of the pwm pin (pin9) Put LED To change the intensity of the light but the problem is in collecting two pwm values ​​if sending two values ​​to joystick1 + joystick2 The lighting becomes intermittent
//////////////////////////////////////////////////////////////////////////

if ( radio.available()) {
radio.read(&value, sizeof(value));

int joystick1= map(joystikValue1, 0, 1023, 0, 200);

int joystick2= map(joystikValue2, 0, 1023, 0, 55);

analogWrite(analogOutPin9, joystick1+joystick2);

How do you get joystikValue1 and joystikVakue2 from value? What type is value? What size is value? What values are in joystikValue1 and joystikVakue2?

Posting only part of your code wasted my time and yours.

///transmiter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CNS, CE
const uint64_t pipe = 0xF0F0F0F0A1LL;

const int analogInPin1 = A0;
const int analogInPin2 = A1;

int joystikValue1 = 0;
int joystikValue2 = 0;

void setup() {

radio.begin();
radio.setChannel(115);
radio.openWritingPipe(pipe);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate( RF24_2MBPS );
}

void loop() {

joystikValue1 = analogRead(analogInPin1);
joystikValue2 = analogRead(analogInPin2);

if (joystikValue1>=0 and sensorValue1 <= 512){
int joystick1= map(joystikValue1 , 0, 512, 0, 210);
radio.write(&joystick1, sizeof(joystick1));
}

if (joystikValue2>=0 and sensorValue2 <= 1023){
int joystick2= map(joystikValue2 , 0, 1023, 200, 255);
radio.write(&joystick2, sizeof(joystick2));
}
}

///////////////////////////////////////////////////////////////////////////////////////////////

//resever

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CNS, CE
const uint64_t pipe = 0xF0F0F0F0A1LL;

const int analogOutPin4 = 9;
int value = 0;

void setup() {

radio.begin();
radio.setChannel(115);
radio.openWritingPipe(pipe);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate( RF24_2MBPS );
radio.openReadingPipe(1,pipe);
radio.startListening();

}

void loop() {
if ( radio.available()) {
radio.read(&value, sizeof(value));

if (value >= 0 and value <=200 ){
int joystick1 = value; //
analogWrite(analogOutPin1, joystick1);
}

if (value >= 201 and value <=255 ){
int joystick2 = value-200; //
analogWrite(analogOutPin1, joystick1+joystick2);
}

}

I want value to analogOutPin1 = 255 if joystick1=200 and joystick2 = 55

You send two messages, with no way to define which is which. One message contains a value from 0 to 210. The other contains a value between 200 and 255. The value 205 could come from either message.

Your receiver code won't even compile.

So what is the solution

So what is the solution

The simplest is to send one message, containing both values.

thank you PaulS

Actually, it succeeded in using a arrey and sending all the values together