processing-to-arduino pulse sensor visualisation

sin wave pulse sensor

Uses the pulse sensor that Yury/Joel made; currently I’m mapping pulse to amplitude of the sin wave (very nifty sin wave using Daniel Shiffman’s equations) although, as usual, I’ve decided to go down the (shiny!!!!) HSB colourmode. Did I mention how much I love HSB???

the processing-recieve code is basically a serial response – it sends strings of ‘b’ (heartbeat) ‘p’ (peak value) ‘t’ (trough value) and ‘d’ (detect) the original one that comes with the sensor is a lot more complicated since it has a ridiculous number of ints(inData) but I cut it down to 4…. and even so, I didn’t use all the variables (compare it to the arduino code, so many ints!). I guess I just wanted to make it easy to edit with, because it’s not really perfect/to my own standards. There’s a bit of jerkyness when the pulse beat drops/rises and debouncing doesn’t really help – it makes it worse since the delay increases the change in amplitude and the coding is kinda hacky – I mapped it as amplitude = float(inData)*1.0f/10. I needed to convert the raw sensor data to frames, but that resulted in something like 81-113 fps/amplitude which made the graphing go crazy, so I divided it by 10 so that it would stay within processing’s 15fps standardisation.

I think improvements would be – gradual the change ‘b’/time(?) since right now ‘b’/beat is a boolean, and the moment it turns true it just snaps the graph (no transition). Map amplitude as ‘p’/peak – ‘t’/trough = drop average, which will give a smoother, more consistent rhythm and if also really *really* think this would be much easier on OF; since I could write it as sin(of_time_elapsed) instead of multiplying frames, dividing it etc etc there’s other things I could change as well, like using xspacing (tighter xspacing for faster heartbeat) and using period. Another thing that might be cool would be to use mimin library and set height as a sound file, so the yvalue will be a ‘note’ on the sound map.

Download code here:


4 thoughts on “processing-to-arduino pulse sensor visualisation

  1. Hey, I just tried your code and it’s not working for me. All that shows up is the gray background. Any tips?

    • Hi Celine, did you test if your pulse sensor is working with the example sketch (it comes with the pulse sensor website)? The sensor is very sensitive to the colour of skintone – some of my classmates couldn’t get it to work because they didn’t have enough blood under their skin to work. You can try clapping your hands until your palms/fingertips turn red, it helps the sensor detect pulse.

      If that still doesn’t work, let me know!

      • Yeah, I did! The example visualiser works… Does it matter what version of processing/arduino code I’m using?

      • no it shouldn’t, did you run both the arduino code and processing code together? they must be run in sync

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s