WesleyCMD
Published © GPL3+

Mind Control Drone

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

IntermediateFull instructions provided23,122
Mind Control Drone

Things used in this project

Hardware components

Arduino MKR1000 & Genuino MKR1000
Arduino MKR1000 & Genuino MKR1000
×1
Micro Racing Drone
×1
Capacitor 100 µF
Capacitor 100 µF
×4
Resistor 221 ohm
Resistor 221 ohm
×4
Jumper wires (generic)
Jumper wires (generic)
×12
Breadboard (generic)
Breadboard (generic)
×1
Mindwave Neurosky
×1

Software apps and online services

Processing 3
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Digilent Screwdriver
Digilent Screwdriver

Story

Read more

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

Code

Processing master

Processing
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 Control

Arduino
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     );
}

Credits

WesleyCMD

WesleyCMD

0 projects • 22 followers
Contact

Comments