How to control a brushless motor with a joystick and nRF24L01?

Thread Starter

iiwudike

Joined Sep 30, 2024
4
Hey guys, I am a beginner in electronics. I need some help. I'm trying to control my brushless motor with my joystick but it's not spinning. All I hear is the beeping from the brushless motor. Like it continuously beeps until I move the joystick, then it rapidly beeps fast, then returns to it's normal paced continuous beeps. So I guess there is some connection, but I don't know why it's not spinning. It may be my code. Down below are my code and the Wiring diagram I'm using.

Code:
Transmitter Code:

#include <SPI.h>
#include <RF24.h>
RF24 radio(8, 7); // CE, CSN
const byte addresses[] = {"1Node"};
struct dataStruct {
  int motorSpeed;        
  } myData;
void setup() {
  radio.begin();
  radio.openWritingPipe(addresses[0]);
  radio.stopListening();
}
void loop() {
  int joystickvalue = analogRead(A0);
  myData.motorSpeed = map(joystickvalue, 550, 1023, 0, 180);
  radio.write( &myData, sizeof(myData));
}

Receiver Code:

#include <SPI.h>
#include <RF24.h>
#include <Servo.h>
RF24 radio(8, 7); // CE, CSN
const byte addresses[] = "1Node";
const byte pipe = 1;
Servo myServo_1;
struct dataStruct {
  int motorSpeed;        
  } myData;
void setup() {
  myServo_1.attach(9);
  radio.begin();
  radio.openReadingPipe(pipe, addresses[0]);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    while (radio.available()) {
      radio.read( &myData, sizeof(myData) );
      myServo_1.write(myData.motorSpeed);
      }
    }
}
1727738982263.png
 
Last edited by a moderator:

KeithWalker

Joined Jul 10, 2017
3,603
What are the power requirements of the motor? An Arduino Uno can only output a maximum current of 40mA per pin. That is not enough current to drive anything but the very tiniest of brushless motors.
 

Thread Starter

iiwudike

Joined Sep 30, 2024
4
What are the power requirements of the motor? An Arduino Uno can not output enough current to drive any but the very smallest of brushless motors.
I have an A2212/13T 1000Kv brushless motor. It's a very small brushless motor. It worked on the Arduino with my 30A ESC and 2200mAh Lipo battery without using the nRF2401.
 

KeithWalker

Joined Jul 10, 2017
3,603
That motor has a no-load current of 0.5A. You don't show an ESC in your diagram. There is no way an Arduino can supply enough output current through its output pins to drive it directly.
 

be80be

Joined Jul 5, 2008
2,394
Power the sevro from you supply power I use a 5 volt wall supply 2.5 amps hook the ground and signal to arduino and supply to servo and the ground to ground on the arduino

Your pic is showing servo motor
 
Last edited:
Top