SleepyTime

By: Emma Brito

Project Description

SleepyTime is a laptop peripheral addition that aims to assist in lulling the user to sleep. Every element of the project seeks to be a relaxing addition when falling asleep. To use Sleepytime the web page hosting it must be open. Then one of three calming instrumental songs will begin to play. The volume of the song is controlled by a light sensor. As the light gets dimmer the music also gets quieter with the goal of gradually lulling the participant to sleep. The light sensor is hidden within a teddy-bear so that nothing seems out of place within a “sleeping” environment. Finally, if the participant chooses to leave the laptop screen illuminated, they will see an animation of twinkling stars in the night sky.

GitHub Code

https://github.com/emmabrito/emmabrito.github.io/blob/master/SleepyTime

Process journal

Brainstorming and Beginnings

Initially I was excited to do this idea with a pulse sensor as the input, and create a relaxing activity that involved a visualization of pulse rates on the laptop screen. I felt that it suited the prompt of “making something for the computer it doesn’t have” very well. After all, laptops and computers often are a source of stress because of their relationship to work. Since we bring them home with us it seems like we can’t get away from stress. This is where a project that focuses on relaxation would come into play. It emphasizes de-stressing.

To create this idea I went to Creatron and purchased a pulse sensor. I worked with the pulse sensor for a while, but I found it difficult to work with. I initially had a hard time getting access to the values. Once I did the sensor itself was unreliable, and when I was able to get readings they were inconsistent. I tried a couple different codes I found on GitHub to see if it made any difference (there were no examples like we have for some of the other sensors because pulse sensors were not included in our initial kits). After playing around with the sensor for a number of hours I decided it was time to modify the project slightly.

New Idea

I still wanted to pursue the idea of relaxation within the project, when I had the idea of taking it to its fullest extent, i.e. sleep. Once I came up with this as the ultimate goal, I quickly decided on a light sensor as the input. Initially I was planning on it having it serve more as a prompt for sleep, with the lullaby turning on once it hits a level of dimness within the room. I altered the intention slightly once I realized that light levels can drastically change from room to room, regardless of the time. Having the web page opened intentionally is the best way to ensure that it is most effective. THis also meant that the project would become more of a sleep assistant.

First Issues

I was easily able to wire the light sensor into the breadboard and upload the code into the serial monitor. This was the first thing that I did. Unfortunately getting started with P5 was not as smooth. I was taking things one step at a time, I made sure my libraries were in order and tried loading an .mp3 into my sketch. I then put it all on my webspace. This led to a number of different errors unfortunately.

screenshot-11

I couldn’t figure out what the issue was, especially since the code was lifted straight from their examples. It was working for other people, but not mine. I deleted everything and re-downloaded the P5 libraries and sketch. It still didn’t work. After going through the index and code once more, the only thing I could think to do was try downloading the libraries yet again and trying the same code and file. Luckily this time it worked! It loaded successfully on my webspace.

This meant that I could finally get to work connecting it to the Arduino. I added the port, console.logs, etc… Once they were both up and running I could then begin making my project. I started with the basic the sound code.

screenshot-16

Adding Variations

I added in my “if” statements for the volume to adjust to the light values ranges. The music will get quieter as the light lowers. I also added in a few more song options and a “random” feature so that there was more variety of the music. This was done in an effort to keep the sound from becoming too repetitive. This appeared on the webspace.

screenshot-17

Issues with the Light Sensor and Sound

Once I tested the whole thing out, I found that the “random” songs was the only aspect of the previous stage that had worked without issue. The volume of the songs were not changing. I tried shining light on the sensor as well as covering it, but there was no difference. I went back to look at the values listed in the “if” statement and compared them to the sensor readings and found that the light values had changed within the room. I adjusted the ranges but still couldn’t find a difference. Since everything else was working, I had a difficult time figuring out what the issue was.

screenshot-19

Ultimately the code in Arduino had to be changed from Serial.print to Serial.write. The volume then would change with lower values of light reaching the sensor, but would not increase in volume once uncovered. This led to another readjustment of the If statement ranges.

screenshot-20

Visuals

Once the sensor and sound system was running properly, I was able to focus on the visuals of the webpage. This had not been my priority because visuals in creating a “sleepy” environment seemed to be less important (closed eyes, and all). Making the web page more appealing to look at was ideal though. Originally I was going to work with visuals of water, but ultimately settled on the night sky. While I wanted to avoid this because of my previous project dealing with the stars I decided it was more relevant and water would be better suited for different audio. Originally I uploaded an image onto the canvas, but it did not enhance the experience very much. I then decided on a GIF because it could easily be looped, and the repetition of it could be hypnotic.

This meant that I had to download the P5 play library, and place it in my file. I separated a series of still images of twinkling stars from a video on photoshop in order to create a loop of five frames for the GIF. I followed the sample code and was able to load them onto the webpage as an animation, although they appear as a GIF. The main issue I encountered with the animation was that it did not fill the entire screen. I found it distracting, so I had to re-export the frames in a larger format. I found that this created a more immersive experience.

screenshot-26

Final Touch

Once everything else was completed, it became time to hide the breadboard. I didn’t want to just place it in a box because this didn’t seem to suit the overall intent of the project. Something related to comfort seemed like the best idea, especially something could have a purpose. I landed on the idea of a pillow or teddy bear that would have the light sensor exposed, but could still be cuddled. This is exactly what I did, with the breadboard in the teddy bear. Moving forward I would like to make this wireless with more variety in music and visuals.

23547019_10214740969780790_1106325090_o 23555263_10214740971620836_1863701914_o

Sketches, Design files, and Photographs

img_2003 img_2004

Above: Two early sketches of how it might be used and set up

featherm0wifi_analoginput_lightsensor_bb

The Fritz followed for the light sensor

Video of the device being used

The music changing sound early on

Project Context

Many of us joke about how our laptops keep us up late at night. They often serve as a tool or insomnia rather than sleep. Additionally, technology is often seen as  stress-inducing rather than relaxing because of it’s association with work. All to say I was interested in figuring out a way to create the opposite effect with the this project. I wanted to create something that would assist in relaxation and have a calming effect on the user. I also didn’t want them to have to think about using the system because that would cause potentially  more stress as well.

References

Sleep Machine App: The connection between this app and my project is obvious. Both incorporate digital technology and the internet to create a relaxing sleep environment. I like how this one can be personalized for each user and offers a wide range of options of nature sounds. If I were to pursue other iterations of SleepyTime, I would like to incorporate the more options for the user. http://www.sleepsoftllc.com/

Sleep Machines: These machines are updated versions of the traditional white noise machine. Rather than playing music, they offer a variety of other soothing sounds. Most involve natural phenomenon, while settings include white noise and pink noise They can now be controlled from devices. https://www.soundofsleep.com/soundsleep/

Sound and Sleep Studies: There have been a lot of studies about how sound can be disruptive to the sleep cycle and the negative health impacts that this can have on people. It can be beneficial however, depending on the kind of noise utilized. Soft, repetitive sounds within a room can drown out other disruptive noises within the room like outside traffic or even a snoring partner. It regulates the sound environment within the space which is crucial to getting a good night of sleep. http://www.huffingtonpost.ca/entry/white-noise-sleep-tips_us_5707e35ce4b063f854df7b5d

P5: I used p5js.org (http://p5js.org) and Make: Getting Started with p5.js for many portions of the code

Arduino Code: I used this code for the light sensor -https://www.arduino.cc/en/Tutorial/AnalogReadSerial

Songs used as lullaby

  • Andy McKee – Rylynn
  • Andy Williams (Acoustic) – Moon River
  • Iron & Wine (Instrumental) – Each Coming Night

Leave a Reply