Introduction: FADing (Fall Asleep Device)

This device is a gift I have made and offert several times since 2 years. The version I made for this tutorial is the most complete of all because it takes into account the suggestions I've had in the past. I would also point out that English is not my fluent language but i hope to be understandable.

There are devices that helps you to wake up or fall asleep "naturally" with light. The device I present helps you fall asleep by synchronizing your breathing with the variations of light intensity emitted by it. Inspire by this but with more control and option on it.

With it, you will be able to relax more easily and put aside your thoughts that prevent you from sleeping. Depending on who the device works on and who has tested this principle, you may fall asleep easily in 5 to 15 minutes if it works on you.

The device emits a light whose intensity varies several times per minute. When the intensity of light increases, breathe in, when the intensity decreases, breathe out. During the full cycle, the frequency slowly decreases from 11 to 6 breaths per minute.

UPDATE 1 (27 january 2018) : I added new photos, changed the color of the LEDs as suggested in the comments, add a new LED (blue) inside the box, use thinner wires, sanded the box, redone the bottom plate so that it is slightly larger than its housing so that it stays in place by adjustment, and add Fritzing file. The next update to come will be the rewriting of the program taking into account some brillants comments bellow.

Step 1: The Box

The first models I made were simpler than the one I'm going to detail. These models used only one LED.

A simple small box that can hold an arduino, a relay and a 9V battery can be enough. A LED lights the ceiling, the second added in this tutorial illuminates the device for people who do not fall asleep on their back and now can watch it from the side.

I took advantage of the remaining pieces of wood and Solidworks software to size the box.

For a box with harmonious dimensions that doesn't look too high or too big, I use the golden ration which is 1.61. The base is a cube of 60mm, its total height has been defined by the calculation 60 x 1.61 that give around 97mm.

I used a circular saw to cut to size and a router to dig the inside of the box.

Acrylic cutting and drilling was done between 2 pieces of wood to prevent it from breaking.

I had planned to keep the bottom cover with magnets but the use of too big wires does not leave me enough space. While waiting for a next update with the use of thin wires, the lid is held in place tightened in its housing.

The upper part is screwed from the inside of the box.

The LED and inside acrylic are painted blue with a marker. /!\ Update. I sandpaper the blue on the acrylic inside the box to manage different light color from inside.

Step 2: The Electronics

You just need :

  • 1 Arduino Nano
  • 1 10K Resistor
  • 1 Diode 1N4007
  • 2 LED (1 more for the update)
  • 2 push buttons
  • 1 9V batterie connector
  • 1 4.5V Relay
  • 1 small prototyping board piece

I use the free software Fritzing to think about the schematics and draw a prototyping board trace.

There is no battery discharge when the unit is turned off. A long press on the start button allows the arduino, once it finish start, powering the relay itself with its D4 output.

The diode protects the arduino from the 9v battery.

The resistor is for pull up of the mode push button.

One push button is for the startup, the other one is use for several features.

Step 3: The Program

Here the program :

FADing (Fall Asleep Device)

FADing : version 1.0
Made by : Youz
1- Push ON button to power up until you see 1 flash.
2- To add more minutes to the process, you have 5 seconds to add 2 more minutes for each push on the "mode" button.
3- To switch betwin top light or inside light, quick push the "mode" button.
4- To shutdown, long push the "mode" button.
// for change time of default process
int initTime = 8; // initial time of process in minutes. YOU CAN MODIFY IT
// Pin
int led = 9; // the PWM pin the LED is attached to (light for celing)
int mode = A5; // the input pin for the mode button
int pwr = 4; // the power pin to set relay ON through the MOSFET
// Var
int button_delay = 0; // used to check long or short push on mode button
int brightness = 10; // how initial bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
int start = 1; // used for startup
float delayM = 20; // delay between brigtness change for the first 10 seconds
unsignedlong temps; // for compare with millis()
int cyclecompt = 1; // for both 'while'
int buttonCounter = 0; // used for the number of push of the mode button
int lastButtonState = 0; // the last state of mode button
int buttonState = 0; // the current state of mode button
float intervaL = 0; // the interval for slow down fade in/fade out
int md2 = 0; // use for minutes added by push mode button and for fulltime run of the EasySleep
voidsetup() {
temps = millis();
pinMode(led, OUTPUT); pinMode(pwr, OUTPUT); pinMode(mode, INPUT); pinMode(10, OUTPUT);
digitalWrite(pwr, HIGH);
voidloop() {
if (start == 1) { // Run startup loop
if ( millis() >= temps + 10000 ) { // every 10 seconds, fade in/fade out slow down
delayM = delayM + intervaL;
temps = temps + 10000;
if ( temps > md2 * 60000 ) { // check if the selected number of minutes is reach
cycle(); // run 1 fade in and 1 fade out step
voidStarT() {
analogWrite(10, 30); delay(200); analogWrite(10, 0); delay(300); analogWrite(10, 30); delay(200); analogWrite(10, 0); delay(1000); // blink 2 times when arduino boot finish
while (cyclecompt < 500) { // check for 5 seconds the number of time mode button is pushed
buttonState = digitalRead(mode);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
lastButtonState = buttonState;
if (buttonCounter == 0) {
md2 = initTime;
else {
md2 = initTime + ( buttonCounter * 2 ); // Add 2 minutes per push of the mode button
intervaL = 21.0 / ( (float)md2 * 6.0 ); //21 is the interval between brightness change from starting 11 breath per minute (20 ms) to ending 6 breath per minute (41 ms)
start = 0;
if ( md2 != initTime ) { // blink the number of time mode button is pushed
cyclecompt = 1;
while (cyclecompt < buttonCounter + 1) {
analogWrite(10, 50); delay(200); analogWrite(10, 0); delay(300);
voidcycle() { // 1 cycle of fade in/fade out
cyclecompt = 0;
while (cyclecompt < 220) {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if ( brightness <= 10 ) { // On ending invert fadeAmount for next fade in
fadeAmount = -fadeAmount;
if ( brightness >= 115 ) { // If led is full bright, invert fadeAmount to fade out
fadeAmount = -fadeAmount;
if (digitalRead(mode) == HIGH) {
button_delay = 0;
while (digitalRead(mode) == HIGH) {
if (button_delay >10) { //no need to wait for user to release
digitalWrite(9, LOW);
digitalWrite(10, LOW);
if (button_delay < 10) { //short press
if (led == 9) {
for (int fadeValue = brightness ; fadeValue >= 0; fadeValue -= 5) {
analogWrite(9, fadeValue);
digitalWrite(9, LOW);
led = 10; button_delay = 0;
else {
for (int fadeValue = brightness ; fadeValue >= 0; fadeValue -= 5) {
analogWrite(10, fadeValue);
digitalWrite(10, LOW);
led = 9; button_delay = 0;
voidEnD() {
digitalWrite(pwr, LOW); delay(3000);
view rawFADing.ino hosted with ❤ by GitHub

Step 4: How to Use It

To turn the unit on, press the power button until the LED flashes twice. The default operating time of the unit is 8 minutes. If you want to add time, you have 5 seconds after startup to add 2 minutes by short press the mode button. Once the 5 seconds have elapsed, the unit will blink the number of times you have pressed the button and start operation using the ceiling LED.

During operation, if you want to switch between LEDs, press the mode button briefly.

The unit turn off automatically at the end of operation but you can press the mode button for more than one second to shutdown.

Step 5: Conclusion

The device will work best if you don't just spend an hour using your smartphone and you're not too awake.

Not to mention the device, it is important to get in good condition before going to bed and having a quiet time away from the screen 30 minutes before going to bed. With food, sleep is the most important thing for the human body. Food gives strength while sleep gives energy. The lack of sleep leads to depression. It's essential to be able to relativize on all the worries and stress that overcome, to have the mind and body rest to deal with all our problems.

I coming soon update with another pictures and more explanation on the program.

If you need more information for the realization or comprehension of the device, feel free to ask.

- Stéphane

First Time Author Contest 2018

Participated in the
First Time Author Contest 2018

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Epilog Challenge 9

Participated in the
Epilog Challenge 9