Components and supplies
Micro Racing Drone
Jumper wires (generic)
Mindwave Neurosky
Arduino MKR1000
Breadboard (generic)
Resistor 221 ohm
Capacitor 100 µF
Tools and machines
Soldering iron (generic)
Digilent Screwdriver
Apps and platforms
Processing 3
Arduino IDE
Project description
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
1/* 2 * Drone mind control 3 * 4 * This sketch sends Serial values to an receiver receiver 5 * 6 * The input is generated via a Neurosky MindSet Mobile headset 7 * 8 * Created 21 March 2018 9 * By Wesley Hartogs 10 * Communication and Multimedia Design 11 * Avans University of Applied Sciences 12 * 13 * 14 */ 15 16// import Serial libary 17import processing.serial.*; 18 19// Define receiver Serial 20Serial receiver ; 21 22 23// Import MindSet libary 24import pt.citar.diablu.processing.mindset.*; 25MindSet mindSet; 26 27// Set inital values 28int throttle = 0; 29int yaw = 127; 30int pitch = 127; 31int roll = 127; 32 33 34void setup() { 35 36 size(150, 500); 37 38 // Initiate Serial communication at COM10 39 receiver = new Serial(this, "COM10", 115200); 40 41 // Initiate MindSet communication 42 // The MindSet uses Bluetooth Serial communication, 43 // Check the COM-pot in the ThinkGear Connector in your Device Manager 44 mindSet = new MindSet(this, "COM5"); 45 46 // Enable anti-aliassing 47 smooth(); 48 49 // Set stroke properties 50 strokeWeight(5); 51 stroke(255); 52 strokeCap(SQUARE); 53 54 // Set line colour 55 fill(255); 56 57} // setup() 58 59 60void draw() 61{ 62 // Start with a black background 63 background(0); 64 65 // Draw horizontal line to at 40% from bottom 66 // This line indicates the minimum (40%) attention needed 67 line( 0, height*0.60, width, height*.60); 68 69 // Draw a line from the horizontal center upwards 70 // This line gives an indication of your attention 71 // The height is mapped in reverse to get a percentage from top 72 // Example: by 40% (0.4) attention the height value is (100 - 40) 60% (0.6) from top 73 line( width*.5, height, width*.5, height*map( float( attentionLevel ) / 100, 0, 1, 1, 0 ) ); 74 75 // Push the attention level to the throttle variable 76 // 40 = minimum attention needed to do something 77 // 100 = maximum attention 78 // 30 = 8-bit min value for Arduino 79 // 255 = 8-bit max value for Arduino 80 throttle = int( map( attentionLevel, 40, 100, 30, 255 ) ); 81 82 // Constrain values to 8 bit values to prevent errors 83 throttle = constrain( throttle, 0, 255); 84 pitch = constrain( pitch, 0, 255); 85 roll = constrain( roll, 0, 255); 86 yaw = constrain( yaw, 0, 255); 87 88 // When there is communication possible send the values to the Arduino receiver 89 if ( receiver .available() > 0) 90 { 91 println( "attentionLevel: "+attentionLevel+" throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" roll: "+roll ); 92 receiver .write( "throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" roll: "+roll ); 93 } 94 95} // draw() 96 97// Killswitch, press K to reset and close the program 98void keyPressed() { 99 if (key == 'k' || key == ESC) { 100 if ( receiver .available() > 0) 101 { 102 receiver .write("throttle: "+0+" yaw: "+127+" pitch: "+127+" roll: "+127); 103 exit(); 104 } 105 } 106} 107 108 109// MindSet variables and functions 110int signalStrenght = 0; 111int attentionLevel = 0; 112 113public void attentionEvent( int attentionLevel_val ) 114{ 115 attentionLevel = attentionLevel_val; 116} 117 118// This function is activated when the connection with the MindSet is not optimal 119public void poorSignalEvent( int signalNoise ) 120{ 121 // MindSet is adjusting 122 if ( signalNoise == 200 ) { 123 println( "Mindset is not touching your skin!" ); 124 } 125 126 // Map the signal strenght to a percentage 127 signalStrenght = int( map( ( 200-signalNoise ), 200, 0, 100, 0 ) ); 128 println( "Signal strength: " + signalStrenght + "%" ); 129}
Drone Control
arduino
his sketch receives Serial input values (from processing) and sends these values to the hacked controller.
1/* 2 * Drone control 3 * 4 * This sketch receives Serial input values (from processing) and sends these values to the hacked controller. 5 * Use this program only with the Arduino MKR1000 (or another 3.3 volt output based Arduino) 6 * 7 * The circuit: 8 * - 4 Low Pass filters with 100 µF capacitors and 220Ω resistors 9 * - Hacked drone controller 10 * 11 * Created 21 March 2018 12 * By Wesley Hartogs 13 * Communication and Multimedia Design 14 * Avans University of Applied Sciences 15 * 16 * Use this sketch at your own risk. 17 * 18 */ 19 20// Set initial values 21int throttle = 0; 22int yaw = 255/2; // 3.3v / 2 23int pitch = 255/2; // 3.3v / 2 24int roll = 255/2; // 3.3v / 2 25 26int throttlePin = 2; // PWM 27int yawPin = 3; // PWM 28int pitchPin = 4; // PWM 29int rollPin = 5; // PWM 30 31 32void setup() { 33 34 // Begin Serial communication at 115200 baud 35 Serial.begin( 115200 ); 36 37 // Set pinModes 38 pinMode( throttlePin, OUTPUT ); 39 pinMode( yawPin, OUTPUT ); 40 pinMode( pitchPin, OUTPUT ); 41 pinMode( rollPin, OUTPUT ); 42} 43 44void loop() { 45 // When there is an Serial connection available, get the values 46 if ( Serial.available() > 0 ) { 47 throttle = Serial.parseInt(); // Store first interger value from Serial buffer 48 yaw = Serial.parseInt(); // Store second interger value from Serial buffer 49 pitch = Serial.parseInt(); // Store third interger value from Serial buffer 50 roll = Serial.parseInt(); // Store fourth interger value from Serial buffer 51 } 52 53 // Write values to the drone controller 54 // Use a low pass filter or DAC (digital to analog converter) to convert PWM to an analog voltage 55 analogWrite( throttlePin, throttle ); 56 analogWrite( yawPin, yaw ); 57 analogWrite( pitchPin, pitch ); 58 analogWrite( rollPin, roll ); 59} 60 61 62 63 64 65 66 67 68
Processing master
processing
Connects to the MindWave sensor via Bluetooth Serial and sends the attention value as an 8-bits integer to the controller
1/* 2 * Drone mind control 3 * 4 * This sketch sends Serial values 5 to an receiver receiver 6 * 7 * The input is generated via a Neurosky MindSet 8 Mobile headset 9 * 10 * Created 21 March 2018 11 * By Wesley Hartogs 12 * 13 Communication and Multimedia Design 14 * Avans University of Applied Sciences 15 16 * 17 * 18 */ 19 20// import Serial libary 21import processing.serial.*; 22 23// 24 Define receiver Serial 25Serial receiver ; 26 27 28// Import MindSet libary 29import 30 pt.citar.diablu.processing.mindset.*; 31MindSet mindSet; 32 33// Set inital values 34int 35 throttle = 0; 36int yaw = 127; 37int pitch = 127; 38int roll = 39 127; 40 41 42void setup() { 43 44 size(150, 500); 45 46 // Initiate Serial 47 communication at COM10 48 receiver = new Serial(this, "COM10", 115200); 49 50 51 // Initiate MindSet communication 52 // The MindSet uses Bluetooth Serial communication, 53 54 // Check the COM-pot in the ThinkGear Connector in your Device Manager 55 56 mindSet = new MindSet(this, "COM5"); 57 58 // Enable anti-aliassing 59 smooth(); 60 61 62 // Set stroke properties 63 strokeWeight(5); 64 stroke(255); 65 strokeCap(SQUARE); 66 67 68 // Set line colour 69 fill(255); 70 71} // setup() 72 73 74void draw() 75{ 76 77 // Start with a black background 78 background(0); 79 80 // Draw horizontal 81 line to at 40% from bottom 82 // This line indicates the minimum (40%) attention 83 needed 84 line( 0, height*0.60, width, height*.60); 85 86 // Draw a line from 87 the horizontal center upwards 88 // This line gives an indication of your attention 89 90 // The height is mapped in reverse to get a percentage from top 91 // Example: 92 by 40% (0.4) attention the height value is (100 - 40) 60% (0.6) from top 93 line( 94 width*.5, height, width*.5, height*map( float( attentionLevel ) / 100, 0, 1, 1, 95 0 ) ); 96 97 // Push the attention level to the throttle variable 98 // 40 99 = minimum attention needed to do something 100 // 100 = maximum attention 101 // 102 30 = 8-bit min value for Arduino 103 // 255 = 8-bit max value for Arduino 104 throttle 105 = int( map( attentionLevel, 40, 100, 30, 255 ) ); 106 107 // Constrain values to 108 8 bit values to prevent errors 109 throttle = constrain( throttle, 0, 255); 110 111 pitch = constrain( pitch, 0, 255); 112 roll = constrain( roll, 113 0, 255); 114 yaw = constrain( yaw, 0, 255); 115 116 // When 117 there is communication possible send the values to the Arduino receiver 118 if 119 ( receiver .available() > 0) 120 { 121 println( "attentionLevel: "+attentionLevel+" 122 throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" roll: "+roll ); 123 124 receiver .write( "throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" 125 roll: "+roll ); 126 } 127 128} // draw() 129 130// Killswitch, press K to reset 131 and close the program 132void keyPressed() { 133 if (key == 'k' || key == ESC) 134 { 135 if ( receiver .available() > 0) 136 { 137 receiver .write("throttle: 138 "+0+" yaw: "+127+" pitch: "+127+" roll: "+127); 139 exit(); 140 } 141 142 } 143} 144 145 146// MindSet variables and functions 147int signalStrenght = 0; 148int 149 attentionLevel = 0; 150 151public void attentionEvent( int attentionLevel_val ) 152 153{ 154 attentionLevel = attentionLevel_val; 155} 156 157// This function is 158 activated when the connection with the MindSet is not optimal 159public void poorSignalEvent( 160 int signalNoise ) 161{ 162 // MindSet is adjusting 163 if ( signalNoise == 200 164 ) { 165 println( "Mindset is not touching your skin!" ); 166 } 167 168 // 169 Map the signal strenght to a percentage 170 signalStrenght = int( map( ( 200-signalNoise 171 ), 200, 0, 100, 0 ) ); 172 println( "Signal strength: " + signalStrenght + "%" 173 ); 174}
Downloadable files
Single Low pass filter
Convert PWM signal to analog voltage
Single Low pass filter
Controller circuit
Circuit to wire Arduino MK1000 to the hacked controller
Controller circuit
Controller circuit
Circuit to wire Arduino MK1000 to the hacked controller
Controller circuit
Single Low pass filter
Convert PWM signal to analog voltage
Single Low pass filter
Comments
Only logged in users can leave comments