Community /

Measuring stimulus timing with a photoresistor


One of the fundamental challenges with brain research is associating brain activity with some stimulus or cognitive state with high temporal precision. Since a great deal of brain dynamics occur on the timescale of milliseconds, having a VERY precise tag of your stimulus with respect to the brain data is mission critical.

There are a number of ways to measure time. You can count with your fingers, you can count with a clock, etc. One precise approach to measuring the timing of changes on a computer screen is to use a photoresistor (or similarly, a photodiode). Basically, the photoresistor measures changes in light because when light hits the sensor, it modulates the resistance of the photoresistor, which in turn modulates the voltage in your circuit. You can measure this change in voltage using a very simple setup using an arduino and a little bit of code (see here for a simple yet awesome demonstration).

In this post, I’m going to describe our recent efforts to measure the timing of visual changes on a computer using a photoresistor and an arduino (and a few other simple components). If you want to try this at home, here’s what you’ll need:

  1. 32-bit 8 channel OpenBCI board
  2. breadboard
  3. photoresistor (like this one, or get with wires so you don’t have to solder it)
  4. a 220 ohm resistor (this worked best for us, but will vary based on the photoresistor)
  5. (4) Jumper cables
  6. a soldering iron w/ flux

On the software end, you’ll need the Arduino IDE and the firmware, as well as a little Git know how 🙂

The software setup

To use the photoresistor with the OpenBCI board, the firmware needs to be tweaked slightly.  But don’t worry, we’ve already done this for you.  Here’s a link to the Git repo, which you can clone like this:

git clone

Follow this guide to upload the code to the board.


The Hardware Setup

Solder the female headers onto the board

First, we need to solder in these headers that come with the board. To do this, insert the pins and flip the board over to solder the underside.


Solder wires to your photoresistor

Solder your photoresistor to some wires with some shrink tubing to keep everything nice and clean.



Create the circuit

Using the famous ‘murf CAD’ software, we mapped out circuit above.  Here’s a summary of the circuit in words:

3.3 volts -> photoresistor -> D13 pin (this is where we read the voltage into the arduino) -> 220 ohm resistor -> ground.

Now, let’s implement our design. Here you’ll need to gather all the pieces. The arduino, breadboard, photoresistor, jumpers and 220 ohm resistor. Let’s build our light sensor!  First, let’s supply power to the breadboard.  You can do this by connecting a jumper (red) to the ‘VDD’ input on the OpenBCI board:



Now, connect the ground (black) to the breadboard.  There is also a ground input on the board:




Attach the photoresistor (the two black wires):



And the resistor connected to ground:




The jumper (yellow) to read the voltage changes (goes into pin D13 on the board):





And finally, connect the power to the photoresistor (brown wire):




Walaaaah!  The circuit is complete.  Now let’s mount the photoresistor to the computer screen so that we can actually measure changes on the computer monitor:




You are now set up to measure some latencies!


In this post, we summarized one approach to measuring physical changes in light on a computer screen with the OpenBCI board.  There are many possible uses for this.  You could use the signal to associate EEG activity with a stimulus presented to the screen.  You could use it to measure latency differences between hardware and software (as we did here).  You could swap out the photoresistor for another analog sensor, and provide a link between your EEG data and other things in the physical world, like galvanic skin response (GSR), eye tracking coordinates, muscle activity, temperature, touch, you name it!

As I mentioned above, we used this set up to measure hardware/software latencies.  Here is a post with more details on that.

Happy hacking!

One Comment

Leave a Reply