Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Paul Vincent Bezzina
Published © GPL3+

RC Plane Project

Attempting to successfully fly the GASB One outfitted with custom electronics

IntermediateWork in progress16 hours680
RC Plane Project

Things used in this project

Hardware components

Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×2
NRF24L01
×2
Toggle Switch, On-On
Toggle Switch, On-On
×2
Terminal Block Connector
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
A2122 Brushless Motor 2700KV/5T
×1
40A ESC 2S-4S
×1
Glass Fiber and Nylon Propellers
×1
Joystick
×4
Mini-slide switch
×1
Button
×4
Gens Ace G-Tech Soaring 3300mAh 11.1V 30C 3S1P Lipo Battery
×1
HT7333 3.3V Voltage Regulator
×1
10k Ohm Potentiometers
×1
10uF 25V Electrolytic Capacitors
×1
FT232RL
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

RC Receiver

RC Controller

Code

RC Controller

Arduino
#include <nRF24L01.h>
#include <SPI.h>
#include <RF24.h>
#include <Servo.h>

Servo ESC;

Servo s1;
Servo s2;

#define buzzer 7

RF24 radio(4, 5);   
const byte address[6] = "00001";
unsigned long currentTime = 0;
unsigned long lastReceiveTime = 0;

int travelAdjust, Elevatorvalue, thrust, aileronAdjust, ElevatorAdjust2;
boolean Switch;

struct Data_Package {
  byte j1PotX;
  byte j1PotY;
  byte j1Button;
  byte j2PotX;
  byte j2PotY;
  byte j2Button;
  byte pot1;
  byte pot2;
  byte tSwitch1;
};

Data_Package data;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_MAX);
  radio.startListening(); //  Set the module as receiver 

  pinMode(buzzer, OUTPUT);

  ESC.attach(10,1000,2000);
  s1.attach(9);
  s2.attach(8);  
  
}

void loop() {

Switch = data.tSwitch1;
currentTime = millis();

if ( currentTime - lastReceiveTime > 10000 ) { 
  Switch = 1;
  }

if (radio.available()) {
    radio.read(&data, sizeof(Data_Package)); 
    lastReceiveTime = millis(); 
    }
  
if (Switch == 0) {  

  noTone(buzzer);

  thrust = map(data.pot2, 0, 255, 0, 180); 
  travelAdjust = map(data.pot1, 0, 255, 20, 60);

  Elevatorvalue = map(data.j2PotX, 0, 255, (30 + travelAdjust), (150 - travelAdjust));
  ElevatorAdjust2 = (180 - Elevatorvalue);

  aileronAdjust =  map(data.j1PotY, 0, 255, (30 + travelAdjust), (150 - travelAdjust));

if (104 > data.j1PotY || data.j1PotY > 150) {
  s1.write((aileronAdjust));
  s2.write((aileronAdjust));
  ESC.write(thrust);
}

else { 
   s1.write(Elevatorvalue);
   s2.write(ElevatorAdjust2);
   ESC.write(thrust);

   } 
  } else {    
  thrust = 0;
  ESC.write(thrust);
  tone(buzzer, 2000); 

  s1.write(90);
  s2.write(90);

   }
  }

RC Receiver

Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>

//Digital Inputs
#define t1 7  // Toggle switch 1
#define b3 9  // Button 3
#define b4 8   // Button 4

//Potentionmeters 
const int Pot1 = A7;
const int Pot2 = A6;

RF24 radio(4, 3);   // nRF24L01 (CE, CSN)
const byte address[6] = "00001"; // Address

struct Data_Package {
  byte j1PotX;
  byte j1PotY;
  byte j1Button;
  byte j2PotX;
  byte j2PotY;
  byte j2Button;
  byte pot1;
  byte pot2;
  byte tSwitch1;
  byte button3;
  byte button4;
};

Data_Package data;

void setup() {

radio.begin();
radio.openWritingPipe(address);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_LOW);

//Activating internal Arduino Pull Up Resistors
  pinMode(t1, INPUT_PULLUP);
  pinMode(b3, INPUT_PULLUP);
  pinMode(b4, INPUT_PULLUP);

  data.j1PotX = 127;
  data.j1PotY = 127;
  data.j2PotX = 127;
  data.j2PotY = 127;
  data.pot1 = 0;
  data.pot2 = 1;
  data.tSwitch1 = 1;
  data.button3 = 1;
  data.button4 = 1;

}

void loop() {

 data.j1PotX = map(analogRead(A2), 0, 1023, 0, 255);
 data.j1PotY = map(analogRead(A3), 0, 1023, 0, 255);

 data.j2PotX = map(analogRead(A1), 0, 1023, 0, 255);
 data.j2PotY = map(analogRead(A0), 0, 1023, 0, 255);

 data.pot2 = map(analogRead(Pot2), 0, 1023, 0, 255);
 data.pot1 = map(analogRead(Pot1), 0, 1023, 0, 255);

 data.button3 = digitalRead(b3);
 data.button4 = digitalRead(b4);
 data.tSwitch1 = digitalRead(t1);

 radio.write(&data, sizeof(Data_Package));
// Send the whole data from the structure to the receiver
}

Credits

Paul Vincent Bezzina
5 projects • 7 followers
Aspiring electronics enthusiast and sixth form student. Always eager to learn and experiment with new technologies and hands-on creations.
Contact

Comments

Please log in or sign up to comment.