Arduino Projects

Arduino nRF24L01 Joystick for RC Planes, Cars, Boats

Arduino nRF24L01 Joystick:

Arduino nRF24L01 Joystick for RC Planes, Cars, Boats- If you want to make a 12-channels transmitter and receiver to control RC planes, RC cars, and RC Boats using Arduino and nRF24L01, you should read this article from start to finish.

Arduino nRF24L01 Joystick

After reading this article, you will be able to control:

allpcb circuit

A BLDC motor of any rating.

The rudder.

The elevator.

The ailerons.




controlling buttons and switches using Arduino nRF24L01 Joystick

  • With these buttons, you can set the range of servos or connect more servos to control them.
  • With these switches, you can set special aerobatic maneuvers like snap rolls and flips.

I will also explain how to control a large DC motor (775) using a 320A BEC and a High Torque Servo for the steering. You can use the same setup for RC cars, RC boats, and all other radio controlled gadgets.

Additionally, if you want to establish two-way communication between your RC plane or RC car and robots, you can read my previous article. In that article, I discussed the technical specifications of the nRF24L01 transceiver module, its pinouts, how to use different baud rates, how to secure communication, and many other things. I highly recommend you should read this article Master nRF24L01.

Amazon Links:

Arduino Nano USB C type (Recommended)

nRF24L01 RF Transceiver Modules

775 DC Motor

320A BEC

BLDC Motors

RC Planes

RC Cars

RC Boats

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.



Arduino nRF24L01 Joystick transmitter and receiver

The transmitter and receiver are very similar in terms of connections. On both boards, I have added a 5V and 3A power supply.

For smooth operation of the nRF24L01 transceiver modules, I have also added 3.3V power supplies.

The connections for the nRF24L01 with the Arduino on both the transmitter and receiver sides are exactly the same.

You can follow this circuit diagram for the 5V and 3A power supply.

5v and 3A power supply for Arduino nRF24L01 Joystick



For the 3.3V power supply, use this circuit diagram. Read my articles on

how to make 5V and 3A Power Supply.

How to make a 3.3V Power supply.

ams1117 3.3v power supply for Arduino nRF24L01 Joystick

And for the connections of the 2-axis analog joysticks, nRF24L01 interfacing with the Arduino, and buttons connections, follow this circuit diagram.

circuit diagram of buttons with Arduino nRF24L01 Joystick

You can download the Gerber files for Transmitter and Receiver Side PCBs from my Patreon page.

And send it to NextPCB for ordering high-quality PCBs at affordable prices. To check for errors in your PCB design, you can use their free online or offline HQDFM tool. NextPCB also provides component sourcing and PCB assembly services, which I discussed in my previous video on the Hydroponic System Version 1. Get $20 off if you are a new customer who has never placed an order before.



For the receiver side, start with these basic connections.

Arduino nRF24L01 Joystick receiver side circuit diagram

Connect only the nRF24L01 module to the Arduino at first. Because, first; we need to program the transmitter and check if it works properly. If the transmitter works fine, then we will connect the motor and servos on the receiver side.

Also, let me tell you, we will only program the transmitter side once. We will read all the components on the board and send them to the receiver side. Then, on the receiver side, we will decide whether to use the joystick data, the buttons, or all the 12 channels. Anyway, let’s go ahead and take a look at the transmitter and receiver side programs.

nRF24L01 Tx and Rx Programming:

Required Library:

RF24.h

For this, simply copy the library name, then go to the Sketch Menu, then to Include Library, and click on the Manage Libraries.

library installation for Arduino nRF24L01 Joystick based project

Paste the library name in the search box and as you can see; I have already installed this library.




Arduino nRF24L01 Joystick, Code:

Explanation:

This line creates an RF24 object named myRadio with CE pin connected to pin 9 and CSN pin connected to pin 10.

This is a 2D byte array to hold addresses. The address “0” is used here. To make it secure, you can use any combination of letters, numbers, and characters.

The 2-axis analog joysticks are connected to the Arduino analog pins A1, A2, A3, and A4.



All the 6 switches are connected to the Arduino pins 2, 3, 5, 4, 0, and 1.

Next, I defined a structure named package to hold the joystick and switch values.

typedef is used to create an alias Package for the struct package.

This line creates an instance of Package named dataTransmit.

Then inside the setup function, we simply activate the Serial communication at a baud rate of 115200.

Sets the pin modes for the joystick and switch pins to “INPUT” or “INPUT_PULLUP” as needed.

Then we initialized the radio module.

Sets the radio communication channel to 115.

We disable the automatic acknowledgement feature of the radio module. Here are some advantages of doing this:

Increased Speed

Disabling automatic acknowledgment can slightly increase the speed of communication since the radio doesn’t need to wait for an acknowledgment after sending a packet.



Simpler Communication:

For very simple or one-way communication setups, automatic acknowledgment might be unnecessary. Disabling it simplifies the communication process.

Lower Power Consumption:

In certain low-power applications, avoiding the acknowledgement process can save a small amount of power, as the radio doesn’t need to listen for and process acknowledgment packets.

So, if you only need to send data in one direction and you are ok with occasional packet loss then you should disable the automatic acknowledgment feature.

Sets the power level of the radio to maximum.

Sets the data rate to 250 kbps for maximum communication range. There are some other data rates which I have already covered in my previous video.

Opens the writing pipe with the specified address.

Then inside the loop() function, we read the analog values from the joysticks and digital values from the switch pins, and store these values in the corresponding variables. Finally, we open the writing pipe and write the “dataTransmit” structure to the radio module, sending it wirelessly to the receiver.

Now, let’s go ahead and take a look at the receiver side program.



Arduino nRF24L01 Joystick Receiver Code:

Explanation:

We are using the same libraries.

The same CE and CSN pins on the receiver side. CE pin is connected to pin 9 and CSN pin is connected to pin 10.

The same address and structure package.

This time we create an instance of Package named dataRecieve.

Even the code inside the setup() function is exactly the same except these two instructions.

First, we open the reading pipe and then this second instruction puts the nRF24L01 module in listening mode.




Then inside the loop() function; we check if there is data available to read.

Continues reading as long as data is available.

Reads the received data into the dataRecieve structure.

Finally, we print all the values on the Serial monitor.

I have already uploaded these programs, so let’s go ahead and watch this in action.

displaying Arduino nRF24L01 Joystick values on arduino serial monitor

Connect the Receiver to the Laptop/PC and open the Serial Monitor.

As you can see, the joysticks are working, and all the switches are working too. The control sticks are very responsive. In RC planes, we cannot afford any delay or lag. Anyway, our transmitter is completely ready, and now we can use it to control RC planes, RC cars, and other RC gadgets and robots. For the practical demonstration watch the Video Tutorial available at the end of this article.



nRF24L01 Arduino based RC Plane Setup:

controlling rc plane rudder elevator ailerons bldc motor using Arduino nRF24L01 Joystick

This is our setup for the RC Plane. On the receiver side, I have connected one BLDC motor, the ESC signal wire is connected to the Arduino digital pin D3.

The 4 servos are connected to the Arduino pins D5, D6, D7, and D8.

If you don’t know how to install these servos on an RC Plane then you should read my article on RC Plane Designing.

For the connections you can follow this circuit diagram.

controlling rc car and plane circuit diagram using Arduino nRF24L01 Joystick

Now let’s go ahead and take a look at the receiver side program.

Arduino nRF24L01 RC Plane Arduino Code:




Explanation:

On the receiver side, you will also need to add these two libraries. Servo.h for controlling servos and Adafruit_SleepyDog.h for using a watchdog timer.

Create Servo objects.

Define pins for the BLDC motor and Servos.

Package structure remains exactly the same.

Inside the setup() function,

We activate the Serial communication, for the debugging purposes.

Attach each Servo to its respective pin.

Attach Brushless Motor to its pin.

Set all servos to the neutral position (90 degrees)

This set of instructions remains exactly the same.

Finally, set the watchdog timer.

Inside the loop() function,



Elevator Control:

If joystick 2 is moved backward (values 0-495), simply; map these values to an angle range (30-90) and set the elevator servo. If you want to move the servo arm to 0 degrees then replace 30 with 0.

If joystick 2 is moved forward (values 510-1023), map these values to an angle range (90-150) and set the elevator servo. Again, if you want to move the servo arm to 180 degrees then simply replace 150 with 180.

In the similar way, we set limits for all the other servos.

Rudder Control:

If joystick 1 is moved right (values 0-495), map these values to an angle range (150-90) and set the rudder servo.

If joystick 1 is moved left (values 510-1023), map these values to an angle range (90-30) and set the rudder servo.

Aileron Control:

If joystick 2 is moved right (values 0-510), map these values to an angle range (150-90) and set both right and left servos.

If joystick 2 is moved left (values 520-1023), map these values to an angle range (90-30) and set both right and left servos.

ESC Control:

If joystick 1’s vertical value is in the upper half (510 to 1023), map these values to a motor speed range (1000 to 2000 microseconds) and set the motor speed.

So, that’s all about the program, I have already uploaded this program, and now let’s watch the RC Plane control system in action.

Practical demonstration:

Arduino nRF24L01 Joystick based rc plane connections

I successfully controlled the BLDC motor, Rudder Servo, Elevator Servo, and the Aileron Servos. For the practical demonstration watch the video tutorial available on my YouTube Channel “Electronic Clinic”.




Arduino nRF24L01 RC Car:

controlling rc car and boat using Arduino nRF24L01 Joystick

You can use this setup in RC cars, RC boats, and other RC vehicles. I have connected the 775 DC motor with a 320A BEC. I have already written a detailed article about the 775 DC motor. In that article, I also explained some other drivers along with the 320A motor driver.

Anyway, I have connected its signal wire to the Arduino digital pin D3.

With this powerful 25Kg Torque Servo, we can easily control the steering mechanism of the cars and Boats. This means that the servo can turn the wheels left or right. The high torque means it has a lot of power, so it can handle heavy loads and provide precise control, making the car steering smooth and responsive.

Anyway, its signal wire is connected to the Arduino digital pin D5. For the connections you can follow this circuit diagram.

rc car and rc boat ciruit diagram using Arduino nRF24L01 Joystick

Now, let’s go ahead and take a look at the programming.



Arduino nRF24L01 RC Car Program:

Explanation:

This is the same program we used for the RC plane when we were controlling the BLDC motor. But this time, we are controlling a brushed DC motor. So, I just set the range from 1501 to 2000.

Besides this, on the RC plane, we were controlling 4 servos. Whereas, this time, for the car’s steering, we are using only one servo. So, I modified the code, and now I will be able to control the car steering using the 2nd Joystick. I have already uploaded this program, so let’s watch the RC Car wireless control system in action.

controlling rc car using Arduino nRF24L01 Joystick

It worked exceptionally well and I was amazed with the smooth operation and the responsiveness. I controlled the 775 DC Motor and the 25Kg High Torque Servo individually and also at the same time. 

Support me on Patreon for more articles and videos.



Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button