First off, this is a Collaboration between me Guyfrom7up and Gmoon
Gmoon did all of the programming, debugging, etc.
Guyfrom7up did all of the hardware, PCB, etc.
What is Lucid Dreaming? Lucid Dreaming is when you are sleeping and dreaming and that you are aware that your are asleep and that you are dreaming, yet you don't wake up. This can be great, giving you full control of your dreams, jumping off of buildings, going into space, whatever your mind can create.
The Lucid Dream Machine is a pair of glasses that you wear while you are sleeping. About 4 hours into your sleep the AVR microcontroller pulse LEDs that shine through your eyelids. This half wakes you up. The flashing lights helps you become aware (in your sleep) that your are sleeping and dreaming, in doing so you become more likely to be able to control your dreams.
Our Collaboration give you the Lucid Dream Machine.
Sorry, but to watch a video you will have to download it, for some reason the video won't work on both youtube and metacafe.
(gmoon: I tweaked the video and uploaded to my account... I need to do this for all my videos, also.)
Step 1: Supplies
In order to build the device you need:
1x ATtiny13v AVR Microcontroller
2x LEDs (color of your choice, we used red because it works at low voltage, shines through eyelids well, and is cheap)
2x Resistors (value of your choice)
1x SPST or SPDT switch (it's only used as a power switch, so it doesn't matter)
1x Normally off momentary switch
1x Lithium 3volt Watch Battery (we used a CR2032)
1x Lithium Watch Battery Holder (we used a CR2032 holder)
Some way of mounting the device to your face, such as glasses).
Ways of making a PCB or just Prefboard (up to you, we used a custom PCB using toner transfer and Eagle)
An AVR programmer
Step 2: About the Program
--PWM dreaming mode
During startup the LED lights up for approx. 2 seconds to indicate operation.
The device also checks if the input button was pressed and held during power up for those initial 2 seconds. If it was, "immediate mode" is entered: the LEDs begin blinking. This is mostly so guyfrom7up could easily test the hardware without waiting for four hours ;-).
It could also be used for "catnap" type sleep states.
However, we could also add a bit of code to vary the pulse width...whattay think?
The Timer and IRQ setup for the initial wait state
After checking for user input, etc., and setting up the IRQ, the ATtiny13 is immediate placed in sleep mode. In this mode only the timers, clocks and IRQs are functional. Of course, this is a power-saving measure.
Rollover time for a 16-bit counter, per timer scaler value (times approx)--
-----------------------CS00: 13.75sCS01: 110s (1m, 50s)CS02: 3520s (58m, 40s)CS00 + CS02: 14080s (3.91h)
A ~4 hour wait is possible with the CS02 and CS00 flag combination, a clock scaler of 1024. In this state, the IRQ is triggered 4.6 times per second. The WAITING state could easily be fine tuned, by using the 16-bit counter (for durations < 4 hrs) together with the waitstate counter (for longer delays.)
Since four hours is as good a delay as any, a longer-duration waitstate isn't used. A longer delay would be a trivial matter to implement.
NOTE: guyfrom7up has found the waitstate for his AVRs is somewhat greater than 4 hours, while mine is somewhat less. The internal oscillator of the AVR isn't highly accurate, but it's good enough for our needs....
At 4.6 IRQs per second, CPU power consumption should be very low. Of course the AVR cannot be in power-down mode, as that requires an external wake up signal. Ours must be timed internally, so SLEEP_MODE_IDLE is our best choice.
IRQs per second, for each scaler (approx)--
---------------------CS00: 4766 /s (during dream phase)CS01: 593.8 /sCS02: 18.6 /sCS00 + CS02: 4.6 /s (during initial waitstate)
The Timer and IRQ setup for dreaming PWM mode
The timer scaler value changes to CS00 when MODE_DREAMING begins--in order to create the gentle transitions of the software pwm. The duty cycle for the CPU (and IRQ) is much greater (about 4.7K per second.) But the LED duty cycle is much less than it would be with a simple on/off switch. A trade off between cpu and LED current draw...
The overall pulse width (length) of the LED blink is controlled by the MACRO_WIDTH and MACRO_GAP constants. The PWM is handled by incrementing the pwm and transition variables by the constants PWM_VAL and TRANS_VAL. Altering those constants will change how rapidly the PWM "ramps up."
Currently, the dreaming frequency LED pulse rate is approx 1.5 hz.
The current version (0.2b) uses only 438 bytes of flash memory. This is well short of the 1K limit on the ATtiny13.
So adding more features is certainly do-able.
Step 3: The Code
For some reason code isn't showing up right anymore, so I've attached a file with the C program
Step 4: The Circuit Board/Schematic
We used a custom circuit board to make the end project look much cleaner for instructables (and the watch battery holder only worked on a custom PCB). The Circuit board pattern and schematic is posted below, but if you choose to make a PCB it's very likely that you have to redesign it because you won't have the exact same pieces as we do. We left a lot of wire pads so that it would be easy to upgrade in the future (such as adding more switches, LEDs, etc).
Step 5: Soldering
and look into some soldering Instructables such as:
Solder some longs wires to the other side of the resistors and ground. It's easier to make them too long and then cut them shorter than the other way around. The other side is later going to be soldered to LEDs which hover over your eyes.
Step 6: Prepare the Mask
I used a sleeping mask, so some of this might be purely situational, but it's just what I did.
Most masks are made up of 2 pieces of fabric and some squishy foam in the middle for comfort, what you need to do is somehow mount the Lucid Dream Circuit on the mask (above the nose) and cut out eye holes for the LEDs.
To mount the PCB I cut into one of the pieces of fabric and just slipped the PCB between the 2 pieces of fabric.
For eyes I just slowly guessed and check with a pair of scissors (make sure you don't cut the mask while it's on your face!!!)
Step 7: Line Up the Wire
Line up & cut the wire to the correct length where you are going to mount the LEDs over your eyes.
Step 8: Solder on the LEDs
Solder the LEDs to the wires above the eyes. You may want to slip on some heat-shrink before you solder it up to prevent shorts later. Make sure the LEDs are facing the right way!
Step 9: Test It Out!
Test out your finished Lucid Dream Machine! Turn it on, it should be able to shine through your eyelids, then the LEDs should go off and wait for 4 hours, and when you fall asleep they'll start blinking at you.
This will give you a good chance at controlling your dreams.
Have fun with it!
Step 10: Personal Experiences
I, honestly haven't been able to keep this device on for long enough when I'm sleeping for it to start working. For example, 1 night I think I took it off in my sleep without me knowing it, and another night I tossed and turn so much in my sleep in the first hour or so that when I woke up 2 hours from when I started sleeping I found the mask near the foot of my bed. Another night I think I took it off in my sleep...
I will update this once I get a successful experience.
Don't forget to vote!
Third Prize in the
Let It Glow!