playlab LONDON is a community of designers, artists, gamers and coders enthusiastic about deploying the technology of play to positive social effect.

hey, you can just look at posts about:
or or or

drop us an e-mail to hello@playlablondon.co.uk

Learning to say Arduino

Last month I promised you I would make a game with an Arduino and Pulse Sensor. This was a promise made with the happy arrogance of a man who has never even tried to broadcast his pulse over the internet. I speak to you now from the other side of that experiential gulf. Here’s what happened.

It was maybe five years ago now that I heard about ‘Journey to the Wild Divine’, the $400+ meditation tool which comes bundled with a heart rate and skin conductivity sensor. I thought this was utterly remarkable stuff, and the idea of plugging myself into a computer and making a feather float using only the unmistakable power of my own calm was narcotic to me.

Imagine my delight then when, while browsing Boing Boing’s 2012 christmas gift list for ways to appease my family for another year, I came across this lovely little open source Pulse Sensor. A week or so later I was looking at some exciting boxes:


image

Of course I didn’t have any sort of idea how to use it, we’ll get to that. For those that don’t know, an Arduino is an open source microcontroller. If you remember playing with circuit boards and solder in school then this may feel familiar - the Arduino provides a current and allows the user to control the provision and manipulation of that current with code which can be loaded onto the board itself, or run on a computer while taking regular readings from the board.

How does it work?

The Pulse Sensor I am using is called a photoplethysmograph. This is a device which illuminates an organ (the skin in this case) and measures changes in light absorption. In this instance, that change is caused by the pulse wave which travels along arteries and capillary tissue when your heart beats. The analog signal which we read from the board is a fluctuation of voltage caused by the pulse wave itself. It looks a bit like this:

image

The physical setup was pleasingly simple. The Sensor itself needed treating with a little hot glue to keep the circuitry protected from grease and moisture and connects to the Arduino through it’s analog input pin. Once it’s all set up it looks like this:

image

At this stage it’s worth mentioning that pulling raw data from an Arduino and into the browser where I was working with it isn’t entirely trivial, and I wouldn’t have been able to do it so easily were it not for the fantastic Paul King’s Arduino Workshop held at Google Campus just down the road from our offices. Paul had us all loading our boards with Firmata and running a server to expose the data in the browser. Firmata provides a very usable set of calls to communicate with the board and it makes programming for Arduino in Javascript a cinch. For our purposes though, it isn’t practical, and the biggest headache of this project was absolutely figuring out how to get useful and usable data into our chosen environment - browser rendered html/css/javascript.

Getting the data

Using Firmata presents some other issues. The ability to derive an accurate pulse from the raw data relies on a high resolution image of the raw data. I need to be able to ask the sensor what it’s seeing very fast and very frequently, or the data I get back will be difficult to analyse well. The code which comes with the sensor polls the data every 2 milliseconds through the use of an 8 bit hardware timer on the board itself. If I use Firmata on the board then that timer isn’t running, and I haven’t been able to find a way to keep up that polling pace in Javascript, while also running any kind of other logic. Even when drawing a simple graph I would find 7-14 ms gaps in between samples and this just didn’t provide me with the data I need.

It quickly became apparent that running the pulse detection code on the board itself was crucial. The next stage of development was concerned with finding a reliable method to bring the resulting data in over the serial port, and into the browser - where our ultimate goal of course is to build a game. I decided to use Impact as the engine for this project because it’s a great tool for rapid prototyping. Nonetheless, choosing to work in the browser now had other consequences - your web browser can’t usually interface with your computers hardware like this, for security reasons.

Enter Node.js, a slick javascript platform for building network applications. With the excellent Serialport library, this separate tutorial and some last minute coaching on IRC  I was able to pass the BPM variable from the board, through the serial port to a node server which was being sent calls by the apache server running impact. Perfect! Now I can look at this:

image


Building a game

Now we have the data in the right place, we can start building a game around it. One of the advantages of Impact is that it’s shockingly fast to move from nothing at all to a populated 2d context. Within about 20 minutes I had moved from an integer for bpm to a simple side scrolling race game. You play against an AI opponent and try to beat him to the finish line by raising your heart rate.


image


The AI you’re racing against is a bit of a trick - every five seconds it looks at your BPM and adjusts the ‘virtual bpm’ of your opponent to be a small percentage above or below yours for the next interval. At the moment your opponent has a 33% chance of ending up faster than you at any given point so you could say it’s an easy game. We ran a number of trials, it’s pretty fun!


image


Clearly this is a long way from being a polished experience, but it opens the doors to a number of exciting possibilities. In the playlab offices we’ve been throwing ideas around for anything from a canabalt clone (with a special jump pad peripheral!) to a meditation trainer. I’d love to hear from you! We have another pulse sensor coming soon and with a little hackery we’ll have two running with nice long cables on the same machine.

Here’s my question if you’re still reading: There’s something very intimate about your pulse, it’s almost romantic. Especially if there are two people involved! How would you design a game which used this data to make people feel closer to each other? What kind of experience brings people closer together? I’d love to hear your thoughts, ping me on simon@playlablondon.co.uk. Oh and let’s get all the sex jokes out early because I know you’re thinking of some.

you can link to this specific article with this url:
playlablondon.co.uk/45922129678

hey, you can just look at posts about:
or or or

playlab LONDON is a community of designers, artists, gamers and coders enthusiastic about deploying the technology of play to positive social effect.

Use the arrow keys to look around.

Keep Me Company Company is built on the +sum framework and like +sum, KMCC was conceived as an engine for visualising, raising and sustaining an area's Jen ratio, a measure of the social well being of an environment designed by positive psychologist Dacher Keltner. Unlike +sum, KMCC provides a simple narrative frame to ease the player into the game, and a solid set of game play goals.
read more...

KMCC casts players as executives in company which profits from the social feats performed by it's employees. Those playing collect points ('bucks') which accumulate in a central pool to bolster the companies share in a fictional market, against competitors such as UnSociable inc. The game ends when the company has gathered 100% dominance of the market place.

go back

The Keep Me Company Company is a radical non profit adventure in giving more value to doing positive things.

At playlab we are big fans of the idea that a game framework is a potent tool for affecting our behaviour. We created +sum as a technical framework which supports that goal.

+sum allows for the delivery of missions to players, and the ability for players to receive points, give points, share messages and collaborate on completing those missions.

+sum is a framework for the delivery of truly social games. It can give missions to players, and allow for players to receive points, give points, share messages and collaborate on completing those missions.