Introduction: Lucidity Mask
The lucidity mask aims to be an alarm clock that wakes the user up at a point in their sleep when they would feel most awake and to train the user to lucid dream. To accomplish this we will be using an EEG, a device used to measure and record brainwave activity.
The inspiration for our project comes from the dream machine in our favorite movie Inception
For the alarm clock part, the user will input their desired wake up time and also a time interval of a couple minutes.
For example: I want to wake up at 6:30. I would set up my desired time as 6:30 and if I'm willing I would wake up more refreshed 10 minutes before or after 6:30, I would set the time interval to 10 minutes.
This information allows us to monitor the user's sleep cycle and wake them up when they would feel the most awake. We intend to wake them up using blue LEDs because of blue light's intensity and also to simulate a sunrise/blue sky.
To be able to lucid dream, the dreamer must be able to acknowledge that they are dreaming. There are many ways to know that you are dreaming but being aware of these clues is the hard part. However, during sleep, people can become aware of external stimuli which often is interpreted inside their dream. With our mask we can use low intensity light as a form of external stimuli to train the user to be aware of their dreaming state.
The EEG allows us to predict and see in real time when someone enters REM Sleep (Dreaming State) and from there we can signal the LEDs to create a blinking red light in front the user's eyelids in an attempt to make them aware that they are dreaming.
Step 1: Parts
Most of the components in our project are simple and easy to acquire.
1x Arduino Uno
Wire (for this project we used the wires inside a CAT5 Cable)
1x Lab Goggles
1x Wire Crimper
1x Mindflex Headset*
Soldering Iron and Solder
* The original Mindflex game which the headsets come from is no longer produced. There are other versions of the game with the same headset still made by Mindflex but they are very expensive. The best bet you have for finding a cheap EEG headset is on sites like eBay and Craigslist.
Step 2: The Mask
For our first prototype of this project we used cheap lab goggles in place of a normal sleeping mask.
1. Identify the areas you want to insert your LEDs into the mask.
For our mask we were able to remove the vents placed in the mask to give us two holes on each side to work with. The mask that I provided in the step above also includes the vents mentioned.
2. Create your LED circuit.
The circuit we used was originally the one included above but we decided to double the amount of LEDs to allow us to have two lights per hole. Instead of four connections shown above we actually have eight. Make sure to included a resistor in your circuit, you don't want to blow out the LEDs.
The power source is the arduino.
We are only using the red and blue components of the RBG LED because of reason's explained in the introduction.
Check that your circuit works. You can do this by plugging the ground into the ground on the arduino and plugging either the red or the blue wire into the 3.3 or 5v power supply on the arduino. Test both colors.
The lights can then be bent to fit the holes. If you have trouble keeping other wires from touching each other, like us, use electrical tape to separate them.
3. Covering the mask.
We want to cover the mask to prevent any light from coming in, like a normal sleep mask. This part can be creative but for our project we covered the mask in duct tape which worked fairly well. Make sure to secure your LEDs in place when performing this step.
We crimped the ends of each section in our circuit that plugs into the arduino. You can see this in the first picture. This helps the wires stay inside the arduino pins.
Step 3: Code for the Mask Lights
You can see from the picture above that we have the wires for the red and blue sides of the RGB plugged into the 10 and 12 digital pins and the ground plugged into the 5v on the arduino.
The code for the mask is fairly simple. We just want to assign two of the digital pins so that we can change their power to on and off. The code is below.
Step 4: EEG Hacking
To use the EEG's data we have to open it up and change some things. We followed this helpful tutorial.
1. Opening the EEG
We need to access the circuit board of the EEG. In order to do this, we unscrew all four screws on the side of the EEG with the ON/OFF switch and LED indicator. After removing the white plate, you will see a board that matches that in the top picture.
2. Soldering to the T pin
Next, at the bottom left corner of the raised board signified by a "QC PASS" sticker in this picture (maybe not in your case, we need to solder a wire to the pin labeled "T". Before soldering your wire to the T pin, you want to plan where your wire will exit the plastic housing in order to to connect to the Arduino. We chose to lead the wire out of a small hole in the bottom left of the plastic housing, but if is more convenient to you, you can chose to file out a small unused section of the plastic to lead the wire out, or leave the remaining white half of the container off altogether. Keep in mind we have one more wire to solder to the board. Whichever you chose, plan you soldering position accordingly. Next strip both ends of a wire long enough to reach the Arduino in whichever configuration you chose, make sure to leave enough extra wire to keep it slack as not to put stress on the soldering point. From here, solder one end of the wire to pin labeled "T" on the board and in the diagram. Connection to this wire is where we will get all raw EEG data from the MindFlex toy.
3. Soldering the ground
Now, strip the ends of another wire and solder one end to any of the grounds on the MindFlex to share with the Arduino.
4. Connecting to the Arduino
For this step, you just need to connect the wire leading to the "T" pin to the RX pin on the Arduino. The ground goes to the ground.
5. Code for Arduino
Use the provided Arduino Brain Library and open up the BrainSerialOut. Upload this code to your board in order to see raw data in the Serial Monitor.
Now you have finished all the steps to seeing raw data from the toy EEG, you can now test to see the wave output.
Step 5: Data
With the Mindflex on and connected to the Arduino, open up the Serial Monitor and you should see data beginning to roll down the monitor. The data is separated into different columns representing different brain waves. Skip the first three columns and the rest are organized as:
Low Alpha: eyes closed, relaxed
Low Beta: alert, focused
Low Gamma: multi-sensory processing
We ran an experiment where one of us would close our eyes and relax for 20 seconds then open our eyes for 20 seconds. We expected to see a decrease in Alpha waves when our eyes were opened.
The first graph above shows the averages of each brainwave graphed.
The next graph shows the percent change in each brainwave going from eyes closed to open.
Step 6: Future...
This is as far as we have gotten for now, but from here, these are the basic steps we will aim for.
1. We will run the raw data through a program that will track where a user is in the sleep cycle, based on the brain waves the EEG is sensing.
2. Having an idea on where the user is in the sleep cycle, we will use a predetermined time period, set by the user, for their wake up time. During this time period, at whatever point the user will be closest to being awake, we will wake them up using the LEDs as an alarm. We want to make sure that the program recognizes when a user is raising in the step of sleep, and when they are descending. For example, if the user wants to wake up between 5:30 and 6:00, and the user begins to descend into deeper sleep at 5:30, the alarm will immediately be set, as opposed to waiting for the next cycle to bring them closer to being awake.
3. Using the same program previously described, we will notify users when they are entering REM sleep by flashing red LEDs. This way, the user will become aware they are in a dream, or "lucid".
4. There is new research in the field of using light frequency for pain relief/therapy. This is a possible avenue for our mask down the line, as we deal with flashing LEDs.
We have a be nice policy.
Please be positive and constructive.