I made a Waking Pillow totally by Arduino as my CruftFest project. As a pillow, it can definitely help us sleep soundly, showing the time and date on the LCD screen which is in the corner of the pillow. Since there are quite a lot of people having trouble with getting up early, another function of the Waking Pillow is to help us get up, so we can set alarm time before sleeping. When the alarm time is met, the pillow will begin to play the music with LED blinking and vibration, which will not stop unless you lift your head from the pillow. If your head lies back, all the wake-up operations will execute again, which can be stopped by pressing the button to turn the alarm off or snooze for another ten minutes.
1. Basic Parts: Pillow x 1, Arduino Uno x 1, 9V Arduino Adapter x 1, 9V Battery x 1, Wire, Pin Header, Breadboard
2. Time Display Parts: DS1307 Real Time Clock Kit x 1, LCD Keypad Shield x 1
3. Wake-up Parts
3.1 Sleeping Check: Button x 1, 10k Resistor x 1
3.2 Music: Piezo Element x 1
3.3 Blinking: Blue LED x 1, 560 Resistor x 1
3.4 Vibration: DC Motor x 1, Transistor P2N2222AG x 1, Diode 1N4001 x 1, 2.2k Resistor x 1
According to following figure drawn by fritzing, wire up all the parts listed above.
All the code and libraries can be downloaded here.
1. Set time for alarm clock: The DS1307 is the most popular real time clock (RTC), and works best with 5V-based chips such as the Arduino. As long as it has a coin cell to run it, the DS1307 will tick along for a long time. Therefore I chose it to keep track of time. I downloaded JeeLab's excellent RTC library RTClib - a library for getting and setting time from a DS1307. Run the code in the example folder to keep the time of alarm clock same as my computer’s.
2. Display time and date on the LCD screen: I made use of LCDKeypad and LiquidCrystal libraries to realise the display staff. In normal times, it will just display the time and date.
3. Finite State Machine (FSM) design: When I was an undergraduate, I once used FSM to design a FPGA-based traffic lights controller system. Therefore, I decided to apply FSM to my waking pillow rather than using a lot of if…else… functions. It may be a little bit complicated to explain by words, so I draw a picture shown in the figure bellow to show how the states transit. The blue circles are the main modes of operation. The red arrows show the directions of state transitions. The words near the red lines mean which button on LCD Keypad Shield will trigger the transition. For details on the operation, I wrote comments in the code.
4. How to wake you up: When the alarm time is met, the buzzer will play a melody by tone function from Sherlock Holmes BBC TV series which has been stored in an array. The blue LED will blink according to the rhythm of the music, stored in an array as well. Meanwhile, the DC motor will keep vibrating. All the operations above will not stop until the button inserted in the pillow is not pressed by the people sleeping on the pillow. If you lie back and press the button, the music, LED blinking and vibration will execute again. Only if by pressing the specified buttons on LCD Keypad Shield, can you trigger the state from WAKE_UP to others, either to SHOW_TIME_ALARM_ON for snooze or SHOW_TIME. In this way, the waking pillow could wake people up successfully.
There are two main challenges I met in the process. One is how to make my pillow realise all the functions I want. The other one is how to check whether someone is sleeping or not. The former one can be solved by Finite State Machine. For the latter one, I used FSR to detect, but it did not work well as the pillow is so soft. Therefore, I just used a button inserted in the bottom of the pillow, which won’t make people uncomfortable when lying down. I also used my Waking Pillow for two nights as an experiment, and it was successful in waking me up.