Project tutorial

Mind Control Drone © GPL3+

Learn how to lift-off a drone with your mind and a hacked controller using a MindWave sensor, Arduino MKR1000 and Processing.

  • 32,620 views
  • 23 comments
  • 138 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
A4kb1xynkid5ebvjyil7
Digilent Screwdriver

Apps and online services

About this project

Background

I find drones fascinating, those little flying machines that can do about anything. When I got the opportunity to do a project with cool technology I decided to make a boy's dream come true, controlling a drone with your mind.

In the research, I did for this project I didn't find any tutorials that covers how you can hack a drone controller easily. Most of the tutorials available are about how you can create your own drone using an Arduino or how to hack the transmission protocol.

This tutorial covers the most basic concept of hacking a PCB to control it digitally. The aim of this tutorial is to learn you the basic concepts that will enable you to experiment on your own with a drone and create something fun.

Notices

You potentially can kill your drone or the controller and make it unusable.

This project will not cover how to steer your drone only lift-off and landing.

You don't necessarily need a MindWave / EEG sensor, you can use any input you want. But controlling a drone with your mind is pure awesomeness!

Video tutorial

Skills you need

This tutorial assumes you have some kind of experience with soldering and desoldering.

Parts list

  • Drone + controller
  • Soldering Station + accessories (braided copper wire, desolder pump, helping hand, solid core wires, tin)
  • Multimeter
  • MindWave sensor
  • Arduino MKR1000
  • Breadboard
  • 4x 100uF capacitors
  • 4x 220Ω Resistors
  • 12x Jumper wires
  • 6 Crocodile clip wires (optional)

You also need 4 resistors with an not yet know resistance value.

Phase 1: Drone PCB

You can use almost any drone you want. Most of the controllers work with two-axis joysticks. Those joysticks we are going to bypass.

First, open the case of your controller. This controller uses two 1.5v batteries which are approximate 3.3v. This value is the same as the output of the Arduino MKR1000.

It is possible to use another Arduino of your liking, but be aware you can break the circuit board if you give it more voltage that the PCB can handle. ( I speak from experience. )

Mesure with a multi-meter what the middle, high and low voltages are of the joysticks once powered. Write them down for later use.

Desolder the joystick components from the PCB.

In reality these joystick components are just potentiometers. A potentiometer is an analogue variable resistor. You can mesure the maximum resistance with an multimeter. Connect the multimeter to the + and - to read the resistance.

Solder (in this case 10Ω resistors) 4 resistors on the holes of the + and - of the joysticks to complete the circuit.

Also, solder solid core wires to the + (B+ on this board) and - (B- on this board) ports on the PCB. And solder solid core wires to the signal ports of the joysticks.

Now you have prepared your controller for the next step.

Phase 2: Digital to analogue

When you use AnalogWrite on with your Arduino the output will be a PWM (Pulse Width Modulation) signal. The win will turn its own value HIGH and LOW in a determined frequency.

Our prepared PCB does not like PWM, it is expecting a steady voltage.

To create an analogue value we can use a variety of digital to analogue converters like a DAC chip or an RF Ladder filter.

Because of that I want to keep this project so simple as possible I will learn you how to use a Low Pass Filter, that will give us the desired output.

To create a Low pass filter you need a capacitor and a resistor.

One of the characteristics of a low pass filter is that the analogue voltage will gradually change (it takes some time). This circuit works best for me because it gives me the desired outcome and uses a low amount of parts.

Phase 3: The Arduino Circuit

The main part of our circuit is the low pass filter we created recently. Make four of them in a row and we have an analogue voltage for all four of the controller inputs.

Connect the right outputs to the correct inputs on the controller PCB. Make sure you got it correctly before uploading the Arduino Sketch.

The standard drone layout is as followed:

  • Throttle => up / down on the left side of the controller
  • Yaw => left / right on the left side of the controller
  • Pitch => up / down on the right side of the controller
  • Roll => left / right on the right side of the controller

Once everything is connected you can upload your sketch to your Arduino MKR1000. You can find the sketch at the bottom of this tutorial.

The Arduino will replace the batteries and can send signals (as voltages) to the bypassed joysticks. At this moment you can build your own programs en experiments to control the drone with PWM.

I will now show you how to use Processing and a MindWave sensor to lift-off the drone.

Phase 4: Mind control

Install all the drivers on your computer. This MindWave sensor comes with a CD.

Pair the MindWave sensor to your computer with Bluetooth. Hold on button up for 3 seconds and the blue led will blink twice, it is now discoverable.

Once connected you start processing.

Install the MindSet library created by Jorge C. S Cardoso for processing from http://jorgecardoso.eu/processing/MindSetProcessing/#download

Unzip the library in your libraries folder. You can find the libraries folder in your processing folder.

Make sure your com-ports are correct in the setup, or you will end up with an error. You can find the com-ports in your device manager.

You can also find the com-port of the Arduino under "Tools" in the Arduino IDE at "Port"

You can also find the com-port of the MindWave sensor in the ThinkGear Connector Preferences (you get this program when you instal the drivers) under "Options"

receiver = new Serial(this, "COM10", 115200);  
mindSet = new MindSet(this, "COM5");

Processing communicates with your Arduino via Serial. You can alter the Processing code to your liking, read the comments in the sketch to understand what is going on.

Run your Processing sketch and concentrate on your drone. When your concentration level goes above 40% the drone will lift off. How harder you concentrate the more aggressive the drone will be. You can land the drone by letting your mind wander off and stop concentrating.

Conclusion

I hope this tutorial gave you some insight on how simple it can be to hack a drone controller (or any PCB) and give it another input. You can figure out with experimentation how to get other inputs to control and how to make other movements in addition to lift-off and land.

I am excited to see what cool stuff you guys will make!

Code

Processing masterProcessing
Connects to the MindWave sensor via Bluetooth Serial and sends the attention value as an 8-bits integer to the controller
/*
 * Drone mind control
 * 
 * This sketch sends Serial values to an receiver  receiver 
 * 
 * The input is generated via a Neurosky MindSet Mobile headset
 * 
 * Created 21 March 2018
 * By Wesley Hartogs 
 * Communication and Multimedia Design
 * Avans University of Applied Sciences
 * 
 * 
 */

// import Serial libary
import processing.serial.*;

// Define receiver  Serial
Serial receiver ;


// Import MindSet libary
import pt.citar.diablu.processing.mindset.*;
MindSet mindSet;

// Set inital values
int throttle   = 0;
int yaw        = 127;
int pitch      = 127;
int roll       = 127;


void setup() {

  size(150, 500);

  // Initiate Serial communication at COM10 
  receiver  = new Serial(this, "COM10", 115200);

  // Initiate MindSet communication
  // The MindSet uses Bluetooth Serial communication, 
  // Check the COM-pot in the ThinkGear Connector in your Device Manager
  mindSet = new MindSet(this, "COM5");

  // Enable anti-aliassing
  smooth();

  // Set stroke properties
  strokeWeight(5);
  stroke(255);
  strokeCap(SQUARE);

  // Set line colour
  fill(255);
  
} // setup()


void draw()
{
  // Start with a black background
  background(0);

  // Draw horizontal line to at 40% from bottom
  // This line indicates the minimum (40%) attention needed
  line( 0, height*0.60, width, height*.60);

  // Draw a line from the horizontal center upwards
  // This line gives an indication of your attention
  // The height is mapped in reverse to get a percentage from top
  // Example: by 40% (0.4) attention the height value is (100 - 40) 60% (0.6) from top
  line( width*.5, height, width*.5, height*map( float( attentionLevel ) / 100, 0, 1, 1, 0 ) );

  // Push the attention level to the throttle variable
  // 40 = minimum attention needed to do something
  // 100 = maximum attention
  // 30 = 8-bit min value for Arduino
  // 255 = 8-bit max value for Arduino
  throttle = int( map( attentionLevel, 40, 100, 30, 255 ) );

  // Constrain values to 8 bit values to prevent errors
  throttle    = constrain( throttle,  0, 255);
  pitch       = constrain( pitch,     0, 255);
  roll        = constrain( roll,      0, 255);
  yaw         = constrain( yaw,       0, 255);

  // When there is communication possible send the values to the Arduino receiver 
  if ( receiver .available() > 0) 
  {  
    println( "attentionLevel: "+attentionLevel+" throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" roll: "+roll );
    receiver .write( "throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" roll: "+roll );
  }
  
} // draw()

// Killswitch, press K to reset and close the program
void keyPressed() {
  if (key == 'k' || key == ESC) { 
    if ( receiver .available() > 0) 
    {  
      receiver .write("throttle: "+0+" yaw: "+127+" pitch: "+127+" roll: "+127);
      exit();
    }
  }
}


// MindSet variables and functions
int signalStrenght = 0;
int attentionLevel = 0;

public void attentionEvent( int attentionLevel_val ) 
{
  attentionLevel = attentionLevel_val;
}

// This function is activated when the connection with the MindSet is not optimal
public void poorSignalEvent( int signalNoise ) 
{
  // MindSet is adjusting
  if ( signalNoise == 200 ) {
    println( "Mindset is not touching your skin!" );
  }

  // Map the signal strenght to a percentage
  signalStrenght = int( map( ( 200-signalNoise ), 200, 0, 100, 0 ) );
  println( "Signal strength: " + signalStrenght + "%" );
}
Drone ControlArduino
his sketch receives Serial input values (from processing) and sends these values to the hacked controller.
/*
 * Drone control
 * 
 * This sketch receives Serial input values (from processing) and sends these values to the hacked controller.
 * Use this program only with the Arduino MKR1000 (or another 3.3 volt output based Arduino)
 * 
 * The circuit:
 * - 4 Low Pass filters with 100 µF capacitors and 220Ω resistors
 * - Hacked drone controller
 * 
 * Created 21 March 2018
 * By Wesley Hartogs 
 * Communication and Multimedia Design
 * Avans University of Applied Sciences
 * 
 * Use this sketch at your own risk.
 * 
 */

// Set initial values
int throttle  = 0;
int yaw       = 255/2; // 3.3v / 2
int pitch     = 255/2; // 3.3v / 2
int roll      = 255/2; // 3.3v / 2

int throttlePin   = 2; // PWM
int yawPin        = 3; // PWM
int pitchPin      = 4; // PWM
int rollPin       = 5; // PWM


void setup() {

  // Begin Serial communication at 115200 baud
  Serial.begin( 115200 );

  // Set pinModes
  pinMode( throttlePin,  OUTPUT );
  pinMode( yawPin,       OUTPUT );
  pinMode( pitchPin,     OUTPUT );
  pinMode( rollPin,      OUTPUT );
}

void loop() {
  // When there is an Serial connection available, get the values
  if ( Serial.available() > 0 ) {
    throttle    = Serial.parseInt();    // Store first interger value from Serial buffer
    yaw         = Serial.parseInt();    // Store second interger value from Serial buffer
    pitch       = Serial.parseInt();    // Store third interger value from Serial buffer
    roll        = Serial.parseInt();    // Store fourth interger value from Serial buffer
  }

  // Write values to the drone controller
  // Use a low pass filter or DAC (digital to analog converter) to convert PWM to an analog voltage
  analogWrite( throttlePin,  throttle );
  analogWrite( yawPin,       yaw      );
  analogWrite( pitchPin,     pitch    );
  analogWrite( rollPin,      roll     );
}

Schematics

Single Low pass filter
Convert PWM signal to analog voltage
Low pass xwscbxfgsy
Controller circuit
Circuit to wire Arduino MK1000 to the hacked controller
Circuit cqz918wrzp

Comments

Similar projects you might like

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 454,665 views
  • 42 comments
  • 236 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 285,485 views
  • 95 comments
  • 671 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 229,313 views
  • 38 comments
  • 236 respects

OpenCat

Project in progress by Team Petoi

  • 195,894 views
  • 154 comments
  • 1,361 respects
Add projectSign up / Login