Creating an Rc Plane With 2 Arduino's

Introduction: Creating an Rc Plane With 2 Arduino's

Making an airplane is a fun challange. It becomes especially challanging when you use arduino's instead af a prebuild controller and receiver.

In this tutorail I will show you how i went about making a radio controlled airplane with two arduino's.

Step 1: What You Will Need.

You will need:

- A brushless motor

- An esc for the motor

- 2 servos

- 1 arduino uno

- 1 arduino nano

- A propeller

- 2 nrf24l01 modules

- 2 10uf capacitors

- Foamboard

- A potentiometer

- A joystick module

- A 3 amp 7.2 volt niMH battery

Step 2: The Radio Controls

I used an nrf24l01 to control the plane. This module has a range of 1 km. You can see how to connect the nrf24l01 in the scheme shown above. You also need to solder the capacitor between the ground and the 3.3 volt to accound for potential voltage drops.

The next step is to get input from your controller. I used an joystick for the rudder and elevator controls and a potentiometer for the motor control. You have to connect the potentiometer to pin A0, I connected the joystick to pin A1 and A2.

Now we need to make the receiver. I used an arduino nano for the receiver because it is smaller. You have to connect the nrf24l01 to this adruino as well. After that you need to connect the servos and the esc(electronic speed controller for the motor) to the arduino. I connected to servo's to pin D4 and D5, the esc was connected to pin D9.

This is the code that i used for the transmitter:

#include <SPI.h><spi.h><br>#include <nRF24L01.h><nrf24l01.h>
#include <RF24.h></nrf24l01.h></spi.h>
RF24 radio(7,8);
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.stopListening();
  Serial.begin(9600);
}
void loop() {
  
  int s = analogRead(0);
  int x = analogRead(1);
  int y = analogRead(2);
  String str = String(s);
  str += '|' + String(x) + '|' + String(y);
  Serial.println(str);
  const char text[20];
  
  str.toCharArray(text,20);
  Serial.println(text);
  radio.write(&text, sizeof(text));
  delay(10);
}

and here is the code for the receiver:

#include <SPI.h><spi.h><br>#include <nRF24L01.h><nrf24l01.h>
#include <RF24.h><rf24.h>
#include <Servo.h></rf24.h></nrf24l01.h></spi.h>
Servo esc; 
Servo sx; 
Servo sy; 
RF24 radio(7,8);
const byte address[6] = "00001";
void setup() {
  // put your setup code here, to run once:
    radio.begin();
  radio.openReadingPipe(0,address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  esc.attach(9); 
  sx.attach(4); 
  sy.attach(5);
  esc.writeMicroseconds(1000); //initialize the signal to 1000
  radio.startListening();
  Serial.begin(9600);
}
void loop() {
  char text[32] = "";
  
  if (radio.available()) {
    radio.read(&text, sizeof(text));
    String transData = String(text);
    //Serial.println(getValue(transData,'|',1));
    int s = getValue(transData,'|',0).toInt();
    s= map(s, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed) 
    Serial.println(transData);
    esc.writeMicroseconds(s); //using val as the signal to esc
    
    int sxVal = getValue(transData,'|',1).toInt();
    int syVal = getValue(transData,'|',2).toInt();
    sx.write(map(sxVal, 0, 1023,0,180));
    sy.write(map(syVal, 0, 1023,0,180));
  }
}
String getValue(String data, char separator, int index)
{
  int found = 0;
  int strIndex[] = {0, -1};
  int maxIndex = data.length()-1;
  for(int i=0; i<=maxIndex && found<=index; i++){
    if(data.charAt(i)==separator || i==maxIndex){
        found++;
        strIndex[0] = strIndex[1]+1;
        strIndex[1] = (i == maxIndex) ? i+1 : i;
    }
  }
  return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}

Step 3: The Fusualage and Stabalizers

Now that you've got your electronics set up, You need a plane to put the electronics in. I used foamboard because it is light and relatively strong. The fusualge is just a rectange that gets thinner towards the tail. The fusualge is not all that important for aerodynamics. The most important thing is that everthing will fit in it while also keeping it as small and light as possible.

The horizontal and vertical stabalizer are faily easy to make. The only important thing is that your stabalizers are perfectly straight. The stabalizers are responsible for keeping the plane stable. When your stabalizers aren't straight, your plane will be instable.

Step 4: The Wings

The wings are probablly the most imporant thing, you need to create an airfoil to generate lift. In the picture above you can see how i made my airfoil.

The most important thing is that the center of gravity of the plane is around the heighest point of the airfoil. this way the plane will be stable.

Step 5: Putting Everthing Together.

Now that we have all parts done, We need to put it all together.

The servo's need to be connected to the stablaizers. this can be done with control rods(see picture above)

The motor need to be put on a piece of foam and glued in front of the plane (or use elestic bands so you can remove it when you need to).

you need a propeller to put on the motor, the size of this propeller depends on the motor. It is very comlicated to calculate the optimal size. But a general rule is that the stronger the motor, The bigger the propeller can be.

For the battery it is recommended to use lipo battery's. however, these battery's need a special charger if you don't want them to explode. That is why i used nimh battery's, these are heavier but easier and cheaper to use.

Share

    Recommendations

    • Fix It! Contest

      Fix It! Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    Discussions

    Looks good. You should enter this into the Arduino contest that is currently running on the site.