Introduction: Control Arduino Using Your Brain and OpenBCI GUI

This tutorial shows you how to get started streaming data from the OpenBCI GUI's Focus Widget via Serial connection to an Arduino UNO Rev3. Specifically, this is designed for use in classroom settings for individuals who have little or no electronics experience. No "hacking" is involved!

Updated January 2023!

OpenBCI hardware and software are open source! Experienced makers have the option of building this project from scratch. Full Documentation: OpenBCI Docs

Grade Level Recommendations and Unit Timeline:

  • Middle School: 2-5 days
  • High School: 1-5 days
  • College: 1-4 days

This includes the time it takes to complete this instructable and then expand the project using the Arduino and available hardware (~60 mins each day). Teachers should complete this instructable before sharing with students and also account for lab setup time before each lesson.

Using just one OpenBCI board with a whole class: The teacher should complete this Instructable and then share with the whole class as a live demonstration, with a few students chosen at random to be the Connected User. Then, student groups can use the recordings in the computer lab with Arduino kits and the GUI in Playback Mode while taking turns using the OpenBCI board.

Skills Addressed:

  • Computer Science: PC to Arduino Serial Communication
  • NGSS: Gather and synthesize information that sensory receptors respond to stimuli by sending messages to the brain for immediate behavior or storage as memories. MS-LS1-8
  • NGSS: Use argument supported by evidence for how the body is a system of interacting subsystems composed of groups of cells. MS-LS1-3
  • NGSS: Develop and use a model to illustrate the hierarchical organization of interacting systems that provide specific functions within multicellular organisms. HS-LS1-2

Flexible Grouping:

  • The Software Operator controls the computer and software.
  • The Connected User is physically connected to an OpenBCI board.
  • The Hardware Specialist helps make sure the Connected User is properly connected.
  • The Recorder takes notes for the group and assists the Software Operator and Hardware Specialist.

Helpful Background Skills:

Supplies

Hardware:

Software:

  • The Arduino IDE(free)
  • The example Arduino sketch (provided)
  • The OpenBCI GUI(free) standalone app or Processing sketch

OpenBCI Getting Started Guides:

Step 1: Review the Scientific Method and Ask Questions

Here is a helpful webpage that describes the scientific method: Science Buddies - Steps of the Scientific Method

Teachers: Start the lesson with a hook of your choice, and then ask students to write down one question on a piece of paper. This question must be directly related to the brain.

Possible Questions:

  • What is the brain?
  • What does the brain do?
  • How does the brain control my body?
  • What makes my brain different from another person's brain?
  • Can a computer read my thoughts if I connect my brain to the computer?
  • How do we measure brain activity?
  • What does EEG stand for?

Step 2: Do Background Research and Construct a Hypothesis

Teachers: Inform students that they will be controlling an Arduino with their brain over the course of this unit.This should make most students excited! Now is the time to share information on the brain, central nervous system, and how this relates to the standards for your grade level.

Transition Statement: "It is important to know the basics of how our brain works if we want to control something outside of our own body, like an Arduino. Let's check out this video to learn more before we proceed."

Video Lecture:BrainWorks: Neuroscience for Kids

Revise Questions: Before students form hypotheses in groups, they should be given a chance to revise or completely change their questions based on the information presented in the lecture or video lecture provided above.

After the revising their individual questions, students in flexible groups will Construct a Hypothesis using the following format:
“If [I do this] , then [this] will happen.”

Step 3: Load the Example in the Arduino IDE

The OpenBCI_GUI-FocusArduino.ino file is designed to serve as a simple starting point for creating your own Arduino project using data from the GUI over serial. Download the .ino file and open with the Arduino IDE.

Step 4: Upload the Arduino Sketch

Connect the Arduino UNO to your computer using a USB cable. After uploading the sketch, you can close or minimize the Arduino IDE, but keep the Arduino connected to the computer. The sketch we just uploaded is running!

Having trouble with this step? Check out the official getting started guide from Arduino.

Step 5: Open OpenBCI GUI in Synthetic Mode

8 Channels will work fine for this example. Click "Start System" to continue.

Step 6: Setup the Networking Widget

Open and setup the Networking Widget as shown in the picture, using Serial mode. We want the data type to be "Focus".

Also, note the baud rate in our Arduino sketch is 57600, so we select 57600 from the Baud dropdown.

Make sure to select the correct port for the Arduino. It's the same port we used to upload the sketch to the Arduino.

Step 7: Open the Focus Widget & Start Streaming

Open the Focus Widget using the dropdown menu.

Then, click "Start Data Stream" at the top left of the GUI.

Next, click "Start" in the Networking Widget. You are now sending Focus data to the Arduino.

Step 8: Simulate Focused State

Next, turn off channel one in the Time Series Widget by clicking on the button to the left of the data.This will simulate a Focused state.

The Arduino's built-in LED should light up when the Focus Widget reads "Relaxing."

If you have a Ganglion or Cyton, proceed to the next step in this instructable to get connected!

Step 9: Get Connected - Part 1

Now that you've got the OpenBCI GUI and your Arduino working and talking to each other, it's time to connect your brain to the computer! At this point, you will need an OpenBCI board and some way to connect leads to the Connected User's head at specific locations. Thankfully, the OpenBCI headband and Mark IV headset make this step easy.

Teachers and Experienced Makers: Please setup the headband electrodes beforehand as outlined in the EEG Headband Guide. This includes connecting the leads to the Ganglion/Cyton. If you are using a Ganglion, you will need to flip switches sw1-sw4 to the down position. This is because we are measuring EEG instead of EMG signals.

To save time and use less wires, this science investigation can be completed with just Fp1, Fp2, and both earclip electrodes. Also, forehead connections use flat electrodes, whereas other sites around the head will use spikey electrodes to account for hair.

In the above picture, the model is using Fp1, Fp2, TP7, TP8, and earclips on both ears. Each notch in the headband corresponds to a site around the head, represented by blue and red circles in diagram. You can see there are four empty spaces between Fp1 and TP7. Connect TP7 and TP8 to the top pins of channels 3 and 4 on the Ganglion as shown in the picture. Connect the earclip electrodes to the top pins of REF and D_G. This is a great configuration to read Focus data from a Ganglion or Cyton board.

Students: The Hardware Specialist and the Recorder will help attach the headband to the Connected User. Don't forget the earclip electrodes! You can check the quality of the connections by checking the impedance of each channel in Step 11. Make sure the electrodes make direct contact with the scalp/forehead.

Mark IV Headset Users: Follow the Ultracortex Mark IV guide to get connected to the OpenBCI GUI.

Step 10: Get Connected - Part 2

Students: Once the Connected User is connected, we can go back to the OpenBCI GUI and go to LIVE (from Cyton) or LIVE (from Ganglion). In the picture above, you can see the Ganglion-1f40 has been detected using the BLED112 dongle. Your teacher should have labeled the Ganglion you are using with your group. Click on your Ganglion from the list and then click Start System.

Teachers: Please label the name of each Ganglion board, or Cyton dongle, during setup/testing. As you can see, it would be difficult for students to tell which board they are using in a multi-board classroom setup.

Step 11: Get Connected - Part 3

Troubleshooting Connection Issues:

  • If the board was unable to connect after pressing Start System, you may need to turn it off and back on again. In some cases, it may help to restart the GUI also.
  • Move the dongle and board closer together.
  • Don't place cell phones close to the dongle or board.
  • Cyton Users: Look for the red LED flash on the dongle, then the blue LED flash. This indicates the computer USB port is recognizing the dongle. If your computer doesn't recognize the dongle, restart your computer (which resets your USB ports). Sometimes, you just need to reset the port for it to be recognized.
  • If you can connect to the board but a channel reads "RAILED", the electrode or ground (ear clip electrodes) may not be connected properly.

Impedance Check:

When using Cyton, you can display the impedance of individual channels by toggling the small Ohm icon to the right of each color coded channel number in the Time Series Widget. When the Ohm icon is toggled on, the board sends a small current through the selected channel to obtain the impedance value. For this reason, you won’t be able to stream data on a channel and obtain the impedance value simultaneously.

To test impedance for Ganglion, use the Ganglion Signal Widget. In the picture above, you can see that Channel 4 has a quality connection (indicated by green circle) while the other channels may not be connected properly (indicated by red circle).

Step 12: Stream Live Focus Data to Arduino

Once you see a steady stream of data from the Connected User in the Time Series Widget, it's time to setup the GUI just like we did in Synthetic Mode at the beginning of this tutorial. Also, you can turn off any channels that aren't being used.

Press "Start" in the Networking Widget to start streaming Focus data to the Arduino.

Teachers: The Connected User should close his/her eyes while focusing on breathing nice and slow, otherwise known as meditating.Sharing this information may compromise the investigation, please use discretion.

If all of these steps have been completed successfully, the other group members will see the Focus widget say that the Connected User is indeed focused! Wow! How cool is that? Celebrate with your group and proceed to take turns trying to see if all group members can get a "Focused" reading.

But how does this work? What is happening? How does the OpenBCI GUI know when someone is focused or not? These are great questions, and we can use this investigation to understand how our brains work to keep our bodies functioning.

Step 13: Analyze Data and Draw Conclusions

Now, each group should have real data from the Connected User's brain that will either confirm or refute the group's hypothesis. According to the scientific method, we should communicate these results by recording what happened, and why it might have happened. If the data does not align with the hypothesis, the group should ask new questions, form a new hypothesis, and experiment again. If the data fully supports the hypothesis, ask the teacher to verify the results.

In any case, it is important for the Recorder to write or type what has been observed. This means recording only information that can be observed. Refer to the examples below:

Observable Data: I saw Sally close her eyes and then I saw the OpenBCI GUI Focus widget read "focused" for 20 seconds.

Non-Observable Data: John said he felt like he was meditating, and I believed him.

Teachers: Once the students have successfully tested and confirmed a hypothesis, direct them to attempt to answer their personal question from Step 1 and then move on to extension activities to expand the project as a group.

Step 14: Next Steps - Examples and Extension Activities

Discussion Points:

  • How does our brain help us outside of the classroom?
  • Does this mean the computer can read my thoughts?
  • What part of the brain does the Focus Widget take into account?
  • Short Answer: The frontal lobe via channel 1 and 2 (Fp1 and Fp2 in 10-20 system)

How can this be used to make something?

For now, let's just stick with Focus data. You can add more to your new Arduino project to react to Focus data from the OpenBCI GUI:

  • Try controlling even more LEDs using the Arduino
  • Try controlling a motor or group of motors
  • Make a second copy of your project and make it a two player game!

Step 15: Extension Activity - Focus Fan! - Part 1

For my extension activity, I decided to have the Arduino control a fan. This allows me to know if I am indeed focused even with my eyes closed, because I should feel a slight breeze. In addition, this should motivate me to focus more so that I can stay relaxed and cool in the summer heat!

  1. I purchased a hobby motor pack with power switches and fan blades via Amazon.
  2. Then, I designed a 3D printed desktop DC motor/fan holder. The current design uses simple internal wiring and power switch. The .STL file is provided in this step.
  3. I printed the fan holder and used an X-acto knife to clean up the edges of slot for the power switch in the back.
  4. I assembled the fan holder by determining the lengths of wire I would need, soldering the wires to the motor, running the all the wires through the fan holder, soldering wires to the power switch, and then snapping the power switch into place.
  5. Also, I super glued a 4xAA battery pack to the bottom for the option of having a portable fan, weighing down the fan on my desk, and having an alternate (and more powerful) power supply.

  6. Next, I followed Arduino Lesson 15. DC Motor Reversing using my 3D printed fan.
  7. Finally, I modified the Arduino Focus code from earlier to include motor control and saved the new file as OpenBCI_GUI-FocusArduinoWithMotor.ino (provided).

Step 16: Extension Activity - Focus Fan! - Part 2

I thought the footprint of the Focus Fan took up too much space on my desk, so I tried to use an Arduino Pro Mini (5 Volt) to make something I actually want to use on a regular basis. Here are the steps I took to create this final prototype:

  1. Using a second breadboard from an older project, I copied the wiring from the Arduino UNO to the Arduino Pro Mini by placing them side by side. I decided I could make do with just a push button switch, so the final prototype does not have a potentiometer.
  2. Next, I transferred the components from the breadboard to a PCB board with just enough space to make all the connections I would need.
  3. I measured, cut, stripped, and soldered the connections on the PCB using solid wire. The battery power will be used to power the fan, while the Arduino functions using USB power.
  4. Next, I decided to attach the PCB board to the 3D printed fan holder using hot glue (as shown in the pictures).
  5. Finally, I modified the Arduino code for the updated design. I assigned the button to toggle the fan power, and saved the new file as OpenBCI_GUI-FocusFan.ino (provided).

Step 17: Reflection

Throughout the process of making this Instructable, I tried to make an accessible experience for others. I feel that neurotechnology education should be accessible for students in middle school and high school, and hopefully this science investigation leads students to a greater understanding of how the brain works. I think a rubric can be used as summative assessment to gauge student learning, and I think it should be added to this Instructable. I would make a five criteria rubric with {0, 1, 2, 3} points for each criterion. At least one criterion should be an individual response, with the others being based on group participation and a final prototype extension activity (e.g. Focus Fan).

Classroom Science Contest

Participated in the
Classroom Science Contest