A small art project controlled by someone's heartbeat.
For a possible installation/exhibition setup the handy PulseSensor is now used to detect someone's heartbeat. This can produce a reasonably accurate estimate of someone's heartbeat just by lightly pressing their finger against the sensor. Earlier prototypes used an AD8232 with an Arduino to estimate the moment of each heartbeat.
The heartbeat data is fed to a raspberry pi which triggers each outward pulse. These pulses flow outward, eventually rippling back in toward the "heart". When they come back, each of them has a chance to drag in a small particle, which will be pushed and pulled by the currents triggered by the user's heartbeat. If these particles are either pulled in to the center or pushed out past the edge of the lights, they trigger a change in the colors used for the heartbeat waves.
The project is a little limited by the hardware used. The RGB LED strips used have pretty decent color ranges, but are only able to control blocks of 3 adjacent LEDs (i.e. the size of one "pixel" in the visualization is 3 lights). Each strip contains 11 such "pixels", so rendering a nice smooth-looking wave is pretty much impossible. The individual LEDs also have much smoother behavior at higher brightness levels. This last point was abused to make the trails on each wave feel a bit more "fluid". A low sine wave is used to filter the brightness of each "pixel" in the trails. Rather than producing a smooth gradient, this has the effect of turning alternating three-pixel blocks on and off, with the effect scrolling in the direction of the wave. This makes for a nice kind of flickering effect, which is a bit reminiscent of rain. Unfortunately it was not captured very well by the camera in the final videos, but it is pretty clearly visible here (an earlier test, driven by a sine wave rather than a real human heartbeat).
The AD8232 is pretty easy to set up, but the ECG data is very noisy, especially when someone is moving (the overwhelming amount of colors at the start and end of some videos are from when the user was moving their arms). The PulseSensor is both easier to use and more robust to body movement, but it is also sensitive to the ambient light conditions and may need to be recalibrated for use in different spaces. Flickering lights in particular will cause lots of false positives.
Originally, the waves produced by each beat were created with a physical fluid simulation. Each beat would introduce a spike in the velocity at one end, which propogated through the fluid to the other side. The intensity of the colors was then based purely on the velocity at any given point, and one nice effect that fell out of this was that the most intense point was not exactly at the forefront of each wave. The additional particles each had a random mass, and were pushed around by the underlying velocity field. This was nice in some ways, but ultimately painful to tune for very specific designed behavior, so the final version is purely time-based and does not involve any physically-based simulation.
The first test after moving away from physical simulation:
After this, a short glow from an edge was added to help show when a particle is pushed into the center or out of the edges, and the timing of the system as a whole was tuned to work better with real heartbeats.