So I'm building a RC drone , I have 4 esc and 4 brushless motors connected to 3,5,6 and 10 pins.
The brushless motor connected to the 10 pin is starting to rotate much earlier then the other one.
I know the pin 10 has a diffrent frequency but how can i fix this issue?
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
Servo esc2;
Servo esc3;
Servo esc4;
Servo esc1;
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
struct Data_Package{
byte joyrightx;
byte joyrighty;
byte joyleftx;
byte joylefty;
};
Data_Package data;
unsigned long lastReceiveTime = 0;
unsigned long currentTime = 0;
void setup() {
esc2.attach(3,1000,2000);
esc3.attach(5,1000,2000);
esc4.attach(6,1000,2000);
esc1.attach(10,1000,2000);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_LOW);
radio.startListening(); // Set the module as receiver
}
void loop() {
if (radio.available()) {
radio.read(&data, sizeof(Data_Package));
lastReceiveTime = millis();
}
currentTime = millis();
if ( currentTime - lastReceiveTime > 1000 ) {
};
Serial.println(data.joyrighty);
esc2.write(data.joyrighty);
esc3.write(data.joyrighty);
esc4.write(data.joyrighty);
esc1.write(data.joyrighty);
}