Introduction: Telekinesis Inspired Brain Controlled Car
The main goal of this project is to harness the power of out minds in order to control electronics. Many other tutorials have touched upon this using EEG headsets to control basic outputs like LED's and motors. However in this project I intend to combine EEG, EMG, and gyroscopic inputs into one headset and make a device capable of effectively controlling an RC car without the use of hands.
Step 1: The Parts
Tools required include a soldering iron, plenty of solder, a screwdriver, and a drill with a small drill bit.
For the base of the project I used an arduino uno however any arduino would work.
For the EEG I chose to use a Mindlfex headset because I found a cheap replacement on eBay. Any EEG headset with the neuro sky EEG chipset will work the same so just use the cheapest one you can find.
An EMG sensor.... I used the myoware muscle sensor (optional)*
The parallax L3G4200G 3axis gyroscope module
4 NPN transistors of any kind
Plenty of jumper cables and wire.
Last but not least an RC car that has a remote controlled by buttons. I do understand that it would be more accurate and precise to use an RC car controlled by joysticks via the use of digital potentiometers but for now to reduce the complexity stick with button remotes.
* the car is completely controllable without the addition of a muscle sensor through the use of the gyroscope however my intention with this headset was to utilize as many inputs from a headset in order to stick with the "telekinesis" idea. Essentially in other applications where more inputs are required like a drone, the same headset can be used as a control device.
Step 2: Preparing the EEG Headset
All headsets with the Neurosky chipset can communicate to the RX pin on the arduino. There is a brain library which is required and can be found here https://github.com/kitschpatrol/Brain . Download it and add it into your arduino IDE. Next take apart the Mindlfex headset and find the Neurosky chip.There should be 2 pins labeled R and T solder a cable to the pin labeled T. Solder another cable to the negative terminal of the headset battery. Then drill an appropriate sized hole on the top of the headset to run the wires through. I suggest that you use a red wire for the transmit pin and a black for ground so you do not get confused when the headset is screwed back together. Connect the red wire to arduino pin 0 (rx) and the black to arduino ground. Go into the brain library and upload the brainBlinker or brainSerialTest to make sure your headset works and is ready. You should begin to see streams of data on the serial monitor with 3 separate numbers for connection, attention, and meditation values.
Step 3: Hacking the Remote
The remote for the car that I used required 2 AA batteries (3 volts) which worked out perfectly because I soldered the two leads to jumper wires which would go in the 3.3 v pin in the arduino. The remote worked perfectly. If your remote uses 3 AA or AAA batteries than the 5 v pin would work. Next for each of the 4 buttons solder a breadboard wire to either side of it. We will be connecting each button to a transistor so we can "press" it digitally. Place the 4 transistors on a breadboard and connect one terminal of each button to the emitter of the transistor and the other to ground. Then connect the collector of the transistor to ground. The base is what will be connected to the digital pins. In my code I have right, left, forward, backward connected to 6,7,8 and 9 accordingly. Test each function separately by modifying the blink sketch with each pin of the car. If a certain function does not work try switching the terminals of the button from emitter and ground.
Step 4: Connecting the Gyroscope
The basics of this gyroscope module are explained terrifically here http://bildr.org/2011/06/l3g4200d-arduino/ I used there source code for the gyroscope input so credit to them. Basically they have provided the diagram on how the gyroscope pins get connected and I didn't change anything about that in my code. I drilled a small hole on the top of the headset and used a spare screw to attach the module in nice and snug. Wear the headset and upload the code found at bildr and test to se if the gyro values respond to slight tilts of the head.
Step 5: Attaching the Muscle Sensor
The muscle sensor like I said is optional and I will provide code that works with and without it. Attach the sensor with double sided tape of glue on the inside front of the headset so when worn the electrodes span across your forehead. The third electrode goes on the temple. Connect the ground and VCC pins. The signal pin goes to A5. once attached and powered on check in a mirror if the red onboard led flashes with a flick of the eyebrows. If not then make sure you have attached everything correctly and that the electrodes are on firmly.
Step 6: The Code
The code can be found here. I have set threshold values based on what I through experimentation found to be most accurate and convenient however I do not think that these values will be the same for everybody. Change the values in the if blocks to what you find works the best. The way I have it, focusing makes the car go forward and raising your eyebrows makes the car go in reverse. Tilting your head to the right turns the car right, and tilting left makes the car go left. a quick nod forward sets the turn shaft of the RC car straight. Tilting your head back stops the car as a kind of brake. Maybe other functions can be added with the utilization of the z axis and the meditation value. This headset has a lot of potential an perhaps in the future I can make more complex "brain" controlled devices than a mere button controlled RC car.
We have a be nice policy.
Please be positive and constructive.