Log in

No account? Create an account


Skyberries and Voidmelons or Voidberries and Skymelons

Previous Entry Share Next Entry

Sleep Art

For the SF0 task, World of Snorecraft, players have to "Enable a sleeping person to create a work of art."

For this task, I took inspiration from the Sleep Time app, which tracks your sleep cycles and can wake you up while in your lightest sleep phase. It does this by using the accelerometer in your phone, to track how much you are moving while you sleep.

I decided to create an app that would let you draw while you were asleep, by reading an accelerometer in a similar way.

I toyed with getting an Apple developer license and using Xcode to read the accelerometer on an iPhone, or using an Arduino with an accelerometer, but in the end I decided upon using Processing and a phone. I then learnt how to use Processing and to read an accelerometer by signing up for a Coursera course on Creative Programming for Digital Media & Mobile Apps.

This is what the app does:

1. For periods where you are not moving much, the app will draw a circle. The bigger the circle, the longer the amount of time you were not moving much. You may have been sleeping quite deeply or were in REM sleep.

2. For periods where you are moving more, the app will draw a square. The bigger the square, the more you were moving. You may have been awake.

3. The screen is divided into 4 sections, each lasting 2 hours.

You can run the app yourself from here:

I've only tried it on an iPhone 4S, so can't guarantee it will work on other phones.

How to make it work on an iPhone 4S:

1. Go to Settings and in the General section, turn Auto-Lock to "Never".
2. Go to http://jodi.freeshell.org/sleepdrawing/index.html
3. Plug the phone in to charge.
4. Put the phone on your bed. (I put mine under my pillow.)
5. Press the screen, so the text goes away.
6. Leave the phone alone.
7. Sleep.
8. Wake up and touch the screen again.
9. The image that has been created will then open in a new tab in the web browser, so you can save it.

Note: Obviously just because you were not moving much doesn't mean you were definitely asleep, but you might have been asleep.

Future development:
Make it delete the picture when you wake up, so the picture only exists when you're sleeping.

From 16th July:

From 21st July:

From 22nd July:
Sleep Art - 22nd July
Tags: ,

  • 1
That's a really cool idea! I'll give that a go tonight with my Android phone and see if it works :)

Gosh, I'm seeing Coursera all over the place at the moment, a friend of mine is doing Science of Gastronomy and Emily is doing Stanford's algorithms course. I've signed up to both; I need to get a move on today if I'm not going to miss a deadline for both!

I haven't tried it on an Android so not sure if it will!

I think the main differences would be that the accelerometer data is likely to be different for Android, so I would need to tweak that a bit.

What it does at the moment is:
1. Gets the largest movement that happened in the last minute, by calculating the distance between the current vector and the previous vector.

If that movement was less than 0.2, then it will draw a circle, but not immediately. It will count how many minutes were less than 0.2 in a row and then the circle it draws will use that.

If the movement was more than 0.2, it will draw a square.

Also, I have set it up for the screen size of the iPhone I have. I guess that would just result in a smaller picture though.


deathboy has an Android, so perhaps I should borrow his and try it, and figure out what tweaks should be made. :)

I have quite enjoyed the Coursera course, but as it was the first one I did, I got confused about deadlines and missed the first one, and now I can't be bothered with the second, but never mind. :)

I found I was getting into the habit of watching too many TV programmes, so watching Coursera videos seems like a good replacement.

A quick test had it working in Opera on Android (but not the stock browser), but when I woke up this morning Opera had disappeared, so I guess it ran out of memory or something overnight? Not surprising, my poor old phone struggles with even Google Maps :)

I am just keeping up with the Algorithms homework - I'll need to do some taste tests tonight or tomorrow if I'm going to get my Gastronomy marks though! Coursera seems like a good substitute for TV indeed.

Thanks for trying it! Not that surprised it ran out of memory - earlier tests with iPhone had that happening too.

I may try to make it draw less frequently. Hmm.

Ooo... I shall just pause a moment while I admire both your ingenuity and the resulting art.

Very cool! I kinda of want to try it out but not sure how I'll like sleeping with my phone under me. Have to make sure I turn off all the notifications! :p

I keep hearing about coursera as we are trying to figure out how best to let our software be used with it. Apparently the whole movement is called MOOCs or Massive Open Online Course and I still kinda giggle whenever I have to go to a meeting about MOOCS :p

This is great. I like the thought-bubble aesthetic, although I suppose the squares would be more likely to correspond to dreams?

I think light sleep would either be little circles (ie, not moving much for a minute or two, followed by moving more) or little squares.

I am confused about sleep stages now. When you're not moving much should be when you're dreaming? So, big circles? Hmm.

  • 1