WIW#1 : Pulse sensor – Teensy – Vizor

By September 19, 2016Workshop

This is the first workshop in series “Wow – it works!?”. The idea of the series is to explore technology and our relationship with it by hacking something (somewhat) functional together, using inexpensive and accessible materials. Besides common sense and natural curiosity, no special skills should be required. Let’s see how it works. This page is a collection of resources for the workshop participants, not a guide documentation as such.

 

Wiw! I can hear and see my heart beat in virtual reality!

Let’s connect a hear beat sensor to small microcontroller, make it to act like a keyboard and send signals to virtual reality software, that pumps a 3D heart on a cheap cardboard VR goggles – shall we.

 

Ingredients

• Pulse sensor
• Breadboard
• Teensy 3.2 microcontroller
• Usb OTG cable
• Android smartphone
• Vizor – online VR authoring tool
• Cheap VR goggles

 

Disclaimer: I’ve done this without blowing up any parts or doing any damage to the phone. However, while it’s very unlikely to harm yourself doing this experiment, it’s quite possible to fry all the electronics used here, by wiring them incorrectly, including the most valuable part, your phone. Pay attention on the instructions and proceed with your own risk.

 

How to hack it together

  1. Plug the Teensy on the breadboard.
  2. Learn how to upload patches (code) on it
  3. Check out Teensy pin-out and learn where are pins: A0, GND and 3.3V out
  4. Wire the pulse sensor on the breadboard based on this info
  5. Upload this code on Teensy (reading heart beats and blinking a LED)
  6. Add few lines of code (making Teensy act like a keyboard and send keypress “g” on every heart beat). See below.
  7. Open this patch on Vizor on Chrome browser on your Android phone and put it on VR mode
  8. Put your phone on your VR goggles and plug the teensy on the phone using micro USB and USB OTG adapter
  9. Clip the sensor on your ear, put the goggles and headphones on and see&hear the 3D heart beat on your pulse
//  Where the Magic Happens
void loop(){
  
    serialOutput() ;       
    
  if (QS == true){                        // A Heartbeat Was Found
                                          // BPM and IBI have been Determined
                                          // Quantified Self "QS" true when arduino finds a heartbeat
        Keyboard.press(KEY_B);            // Send key-press "g"
        digitalWrite(blinkPin,HIGH);      // Blink LED, we got a beat. 
        fadeRate = 255;                   // Makes the LED Fade Effect Happen
                                          // Set 'fadeRate' Variable to 255 to fade LED with pulse
        //serialOutputWhenBeatHappens();  // A Beat Happened, Output that to serial, disabled     
        QS = false;                       // reset the Quantified Self flag for next time 
        delay(20);                        // Small delay
        Keyboard.release(KEY_B);          // Send key-release "g"
  }
     
  ledFadeToBeat();                      // Makes the LED Fade Effect Happen 
  delay(20);                             //  take a break
}
%d bloggers like this: