Arduino, EEG, and Free Will

Using an open source platform to investigate the "readiness potential" and what it says about human free will

Similar projects worth following

A longstanding debate in philosophy focuses on the existence of free will. Do humans have some inherent moral agency, or are our brains just biological machines, subject to the same physical determinism as any other animal? Modern neuroscience can provide some insight to these questions, such as Benjamin Libet's famous 1986 experiments that correlate the EEG readiness potential (RP) with a subconscious decision to perform a voluntary action. In summary, before a subject performs a simple voluntary action (e.g. "Flex your wrist whenever you feel like it"), the secondary motor area generates a characteristic EEG potential over 300 milliseconds before the subject becomes aware that they are going to perform the action. If the brain had already been preparing to perform the action for nearly half a second before the individual consciously "decides" to perform the action, did the individual actually... decide? Since the paper was published, dozens of philosophers and scientists have attacked the paper's methods, arguing that the claims made by Libet are overstretched and that the RP carries very little weight in the free will discussion. In the true spirit of open science, anyone should be able to recreate this experiment, both improving the quality of this debate with additional data, as well as furthering the general public's understanding of neuroscience.

My project aims to allow the DIY community to participate in the discussion by recreating Libet's experiment using just an Arduino and a simple open source shield.

Neurophysiology of Consciousness 1993 Libet.pdf

Paper upon which this project is based

Adobe Portable Document Format - 605.82 kB - 07/11/2016 at 13:48


  • 1 × Arduino Uno
  • 1 × Backyard Brains EMG Spikershield
  • 1 × Backyard Brains Heart/Brain Shield
  • 1 × Headband
  • 2 × Snap fastener studs

View all 8 components

  • Measuring awareness times

    Patrick Glover08/01/2016 at 21:26 1 comment

    Libet had the subjects view an oscilloscope with a dot rotating periodically in a circle, and subjects were asked to retroactively report where the dot was when they first became aware that they were about to perform the voluntary task. He could then calculate the average latency between when the subject reported awareness and when the action actually occurred. I was able to replicate this setup in a more DIY manner.

    I used a continuous rotating servo to turn a balsa wood arm with a period of 1.2s per rotation. Each time the arm of the clock passed over a photoresistor, a custom circuit I put together would return a digital low to the third channel of the arduino that's already recording EMG and EEG on channels 1 and 2. The drop in sample rate to 3333 Hz isn't an issue.

    Unfortunately the clock needs an additional Arduino to drive the servo, since the data logging arduino can't put out enough power to do everything at once.

    Here's the schematic.

    Modifying the MATLAB code to detect the clock passing the 12:00 position was dead simple. The only inconvenient part of this new workflow is the researcher must manually write down all of the integer times reported (1-12) for each wrist flex and enter them one by one during the analysis. I'll work on streamlining it.

    Here's the final result. Mean latency was 218 ms between awareness and action, with a significant RP showing up right as Libet documented at around 1 second before action. Monte Carlo (dotted blue) bars are 2SD from the mean signal (not plotted).

  • Three Channels!

    Patrick Glover07/19/2016 at 13:43 0 comments

    It took a lot of tinkering, but I've finally performed the free will experiment using multiple electrodes on the scalp.

    The hardware setup was fairly simple. Take two more Heart/Brain shields, switch C7 for a 47µF cap on both, and stack them on top of the existing setup using headers. Make sure each shield has a different channel selected by shorting a different pair of pins on the analog out. These BYB shields are like legos for neurophysiology!

    Modifying my MATLAB code to accommodate for three channels wasn't terribly hard. I've updated github.

  • Finally Working!

    Patrick Glover07/06/2016 at 14:12 0 comments

    Now that I've got the ear clip unipolar EEG set up, I'm finally ready to record. I have my subject wear two headbands: one around the head like a normal sweatband and one under the chin and over C3 like in my previous experiments. I had to do a quick test to get the polarity of the electrodes labeled, but now I've got a decent setup working. Positive electrode goes over C3, negative goes on the occiput, and the ground gets clipped to the ear. The subject also wears an anti-static cuff, with the alligator clip attached to the barrel jack of the Heart and Brain shield. Here is some preliminary data:

    It's been a good week! Still plenty of work left to do, since there are some issues with alpha waves, and the RP tends to peak slightly after the action itself. Still, this is some exciting progress. I'm using Audacity to manually crop out epochs that occur during enormous DC spikes that max out the recording software. These huge spikes are obviously not EEG data and probably static discharge or issues with grounding. I'm currently working on writing some MATLAB code to automatically remove these trials consistently.

    The next step is to verify these initial results using a lot of additional trials. Also I plan to add two more EEG channels to provide some spatial data about the propagation of the readiness potential.

  • A big "duh" moment

    Patrick Glover06/29/2016 at 20:14 0 comments

    I had been searching for a readiness potential for weeks, trying to sift through noise two orders of magnitude louder than the signal itself, with little success. This morning Greg, my research mentor, pointed out that since I'm using a bipolar electrode EEG, the op-amp is only magnifying the difference between the two leads over my secondary motor area, which happen to be just a few centimeters apart. The signal between the two electrodes is practically identical, which means I won't be picking up much of anything. Instead, I want to amplify the difference between a lead over the SMA and another lead on some more neutral part of the head.

    To do this, I'm placing one electrode over C3, a second electrode on the base of my occiput, and a reference electrode clipped to my left ear. Instead of buying medical grade EEG ear clips, I soldered two washers to a copper alligator clip.

    Currently in MATLAB, I'm applying a 0.25 - 64 Hz bandpass Butterworth filter. This seems to be a good range for recognizing slow cortical potentials. I kept picking up EKG pulse artifacts when I used two grounds (one on my hand for EMG, one on my mastoid for EEG), so I've removed the EMG ground, which eliminated EKG as well as most cross-talk between the two channels.

  • Debugging and free coffee

    Patrick Glover06/21/2016 at 15:47 1 comment

    Initial results from my first test were... underwhelming. There were a ton of artifacts in the signal. Among these were EOG (electrooculography) and static discharge.

    The eye is a dipole, with the cornea being positive and the retina negative. Electric fields caused by movement of this dipole can result in huge artifacts in scalp potential recordings. There are a few ways to control for this. The first option is to manually remove individual trials that are polluted by EOG movement. The second way is to place additional electrodes around the orbital bone and record two channels of EOG movements while also recording EEG on the scalp. Then we would use some algorithm to subtract EOG movement artifacts from the EEG signal afterwards. Alternatively, I could instruct the subjects to fixate their eyes on a certain point. The issue with this method is it requires the subject to put extra attention on maintaining their eye position, which is a bad confounding factor if our experiment has to do with conscious decision making. The best low-tech solution to this issue is... to have subjects close their eyes. It's not perfect, as the eyes tend to slowly drift when the eyelids are closed, but the reduction in movement is good enough for these purposes. Also alpha waves tend to pollute the signal when the subject's eyes are closed, so my solution to that is to offer subjects free coffee. Caffeine is a known suppressor of alpha wave production, and plus it entices people to volunteer to participate in the study.

    The issue of static is harder to deal with. Wearing an anti-static cuff only gets you so far. Putting down an anti static mat also helps a bit, but there's still a fair deal of DC drift in the signal. Part of me is convinced EEG has a fairly significant voodoo component to it....

  • First Steps

    Patrick Glover06/21/2016 at 15:47 0 comments

    Many EEG experiments are done using 21 electrode helmets to gain better localization resolution. In our case, this will not be necessary. Since the secondary motor area generates the readiness potential, the strongest RP signal is found immediately over that region, contralateral to the side of the body performing the task. In our case, the right hand is used, so our two electrode EEG headband will be positioned over C3 and Cz, according to the 10-20 chart.

    The RP has an amplitude of 1/10th that of an alpha wave, so there will be no way for a human to look at a recording and see the RP building before a wrist flex. We're hunting for a tiny signal in a lot of noise, so the RP will only be visible after a ton of averaging.

    I've got the device built: It's just an Arduino with the Backyard Brains Heart/Brain Shield and the Muscle Shield stacked on top. Analog data from both shields is converted to digital by the Arduino and sent to the computer by USB, where I'm using the free Backyard Brains Spike Recorder software to visualize and record both channels. There are a lot of issues with RF noise, so I've had to look around for a good location away from fluorescent lights and power cables. Perhaps an anti-static wristband would be useful.

    I'm using MATLAB to process the recording, recognize the muscle spikes, and average the EEG signals before and after the onset of the action. This is the tricky part for me, since I have very little experience programming in MATLAB.

  • Intro and Literature Review

    Patrick Glover06/21/2016 at 15:46 1 comment

    Benjamin Libet's 1985 paper titled "Unconscious cerebral initiative and the role of conscious will in voluntary action" was the first ever attempt to correlate conscious decision making with real physiological data. The centerpiece of the Libet experiment was the famed bereitschaftspotential (readiness potential), which is a buildup of electrical activity originating in the secondary motor area, immediately rostral to the motor cortex.

    The potential builds for around 500-1000 ms and peaks right at the onset of activity. In this paper, Libet argued that the readiness potential is an indication of certain areas of the brain preparing to perform a voluntary task. The individual only becomes conscious of the imminent action 200 ms before the action actually occurs.

View all 7 project logs

  • 1
    Step 1

    Assembly of the recording device is quite simple. The EMG and EEG signals each come from their respective Arduino shields, both sold by Backyard Brains fully assembled. If you're interested in building everything from scratch, the schematics are online here and here.

    1. Insert the Heart/Brain shield directly down onto the Arduino so that all the male pins fit into the board's female ports. We want the EEG signal being sent out on channel 1, so short the two pins on analog 1 on the Heart/Brain shield
    2. Our goal is to stack all three boards, but the signal output jacks on the Heart/Brain shield block the EMG shield from fitting effectively. To fix this, we simply add pin header extenders to all the EMG shield's pins. The boards should stack without any issues. We want EMG signal on channel 2, so short both pins on analog 2 on the EMG shield.
    3. Once the shield stack is assembled, load the spike recorder code onto the Arduino, found here. Also, download the free Backyard Brains Spike Recorder software.

    Here is the final product

  • 2
    Step 2

    The next step is to make a bidirectional, one channel EEG headband. To do this, take an elastic headband and insert two snap fasteners roughly 4 cm away from each other on the midline of the band. Any type of headband should work, but avoid any with metallic paints or patterns.

  • 3
    Step 3

    On your subject, secure the headband vertically on the front of their head so that the flat faces of the two metal studs are on C3 and Cz.

    Apply a dab of electrode gel underneath each lead to help conduct signal. This is especially important for subjects with longer hair. Place a single electrode on the left mastoid process. This will be our reference electrode.

    Place one electrode on the back of your subject's right hand, and two on the inside of their forearm, spaced around 15 cm apart, right over the ulnar nerve.

View all 7 instructions

Enjoy this project?



Alexander Chapman wrote 11/02/2023 at 15:28 point

The discussion about using an open-source platform to explore the 'readiness potential' is truly fascinating. It delves into the complex and age-old debate surrounding human free will and determinism. It's remarkable how technology and science continually push the boundaries of our understanding of the human mind.

Speaking of exploration, if you're intrigued by the idea of testing your own limits and pushing the boundaries of your entertainment experience, you might want to consider trying your luck at National Casino. Their wide selection of games and innovative features can add an exciting twist to your leisure time. Check it out at and see how it fits into your journey of discovery and exploration, both in the digital world and the realms of consciousness.

  Are you sure? yes | no

David Matthew Mooney wrote 10/08/2020 at 23:29 point

The volume of commentary on the 1985 paper that your link leads to (the link text says 1993) is amazing, as is the presence of some neurophysiology rock stars like Eccles and Jasper among the commenters. Figure 1, typically the figure that shows the basic discovery, is modified from an earlier 1982 paper involving the same author. An abstract of it can be found here:  This is of interest if you want to know the exact experimental method used to make the discovery. However, access to the full 1982 article costs $36, which I have not coughed up.

  Are you sure? yes | no

Mars wrote 07/31/2016 at 07:01 point

Interesting.  If a signal can be picked up 300ms before a subject is aware of having made their decision, what if that feedback is given to the subject as a tone?  You are sitting there and you hear a tone, which alerts you to the brain activity that results in you deciding to move your hand.  300 ms is longer than the human reaction time.  How could the subject make use of this information?  Could you react by not moving your hand?  Could you react by moving your hand immediately instead of waiting 300ms?  

Suppose you had a gun that could read your EEG.  You are a police officer in a situation with your gun drawn, and you are pointing it at someone, deciding if you are going to shoot or not.  You hear a little beep in your headphones, indicating you are about to pull the trigger a third of a second from now.  You realize this is not the right course of action, and change your mind.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates