Pulse Sensor – Geran Pele, Lizbeth Valentin, Hannah Wheeler

WheelerHannahPulseSensorAssignment.png

In this assignment, we decided to use the pulse sensor with a bar graph display to show a person’s heart rate when working out or exerting themselves. Between 60-120 the display is green, 120-180 the display is yellow, and from 180 – 240 the display shows red. We thought this would be best applied in a glove where the user could wear it while doing activities.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include “Adafruit_LEDBackpack.h”
/*  Pulse Sensor Amped 1.5    by Joel Murphy and Yury Gitman   http://www.pulsesensor.com
———————-  Notes ———————-  ———————-
This code:
1) Blinks an LED to User’s Live Heartbeat   PIN 13
2) Fades an LED to User’s Live HeartBeat    PIN 5
3) Determines BPM
4) Prints All of the Above to Serial
Read Me:
 ———————-       ———————-  ———————-
*/
#define PROCESSING_VISUALIZER 1
#define SERIAL_PLOTTER  2
//  Variables
int pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0
int blinkPin = 13;                // pin to blink led at each beat
int fadePin = 5;                  // pin to do fancy classy fading blink at each beat
int fadeRate = 0;                 // used to fade LED on with PWM on fadePin
// Volatile Variables, used in the interrupt service routine!
volatile int BPM;                   // int that holds raw Analog in 0. updated every 2mS
volatile int Signal;                // holds the incoming raw data
volatile int IBI = 600;             // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false;     // “True” when User’s live heartbeat is detected. “False” when not a “live beat”.
volatile boolean QS = false;        // becomes true when Arduoino finds a beat.
// SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS
// PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer
// SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter
//      run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L
static int outputType = SERIAL_PLOTTER;
Adafruit_24bargraph bar = Adafruit_24bargraph();
uint8_t b = 0;
void setup(){
  pinMode(blinkPin,OUTPUT);         // pin that will blink to your heartbeat!
  pinMode(fadePin,OUTPUT);          // pin that will fade to your heartbeat!
  Serial.begin(115200);             // we agree to talk fast!
  bar.begin(0x70);  // pass in the address
/*
    for (uint8_t b=0; b<24; b++ ){
    if ((b % 3) == 0)  bar.setBar(b, LED_RED);
    if ((b % 3) == 1)  bar.setBar(b, LED_YELLOW);
    if ((b % 3) == 2)  bar.setBar(b, LED_GREEN);
  }
  */
  bar.writeDisplay();
  //delay(2000);
   // IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
   // UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
//   analogReference(EXTERNAL);
  interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS
}
//  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
        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.
        QS = false;                      // reset the Quantified Self flag for next time
  }
  //ledFadeToBeat();                      // Makes the LED Fade Effect Happen
  //delay(20);     //  take a break
  b = map(BPM, 60, 240, 0, 24);
  if(BPM >= 180){
  bar.setBar(b, LED_RED);
  bar.writeDisplay();
  delay(50);
  bar.setBar(b, LED_OFF);
  bar.writeDisplay();
  }
   if(BPM < 180 && BPM >= 120){
  bar.setBar(b, LED_YELLOW);
  bar.writeDisplay();
  delay(50);
  bar.setBar(b, LED_OFF);
  bar.writeDisplay();
  }
   if(BPM < 120){
  bar.setBar(b, LED_GREEN);
  bar.writeDisplay();
  delay(50);
  bar.setBar(b, LED_OFF);
  bar.writeDisplay();
  }
  /*
  for (uint8_t b=0; b<24; b++) {
   bar.setBar(b, LED_RED);
   bar.writeDisplay();
   delay(50);
   bar.setBar(b, LED_OFF);
   bar.writeDisplay();
 }
 */
 /*
  for (uint8_t b=0; b<24; b++) {
   bar.setBar(b, LED_GREEN);
   bar.writeDisplay();
   delay(50);
   bar.setBar(b, LED_OFF);
   bar.writeDisplay();
 }
 for (uint8_t b=0; b<24; b++) {
   bar.setBar(23-b, LED_YELLOW);
   bar.writeDisplay();
   delay(50);
   bar.setBar(23-b, LED_OFF);
   bar.writeDisplay();
 }*/
}
void ledFadeToBeat(){
    fadeRate -= 15;                         //  set LED fade value
    fadeRate = constrain(fadeRate,0,255);   //  keep LED fade value from going into negative numbers!
    analogWrite(fadePin,fadeRate);          //  fade LED
  }

Switch – Hannah Wheeler

In this assignment, I looked at the powerpoint, slide 75, to get a reference for the setup of the circuit. After creating this, I added another loop for the second LED light and set up the pin in the code. Finally, I tried various organic objects, like bananas, oranges, and water but the only thing I could find that would be conductive without fail was metal of some kind. That led me to my earrings where I used alligator clips to open and close the switch.

WheelerHannahSwitchAssignmentCode.pngWheelerHannahSwitchAssignment1

Introduction – Hannah Wheeler

Hello! My name is Hannah Wheeler 🙂

I have taken Programming for Media Arts which is about the extent of my knowledge in programming. In electronics, I don’t believe I have taken the time to really delve into learning about electronic systems too much, although I was on a robotics team in grade school (haha).

I really enjoy working with textiles and after working in the DC Fabrication Lab, I feel more confident in my woodworking skills. I’m also proficient in InDesign and Photoshop.

Mother Dirt! was such a cool article to read especially since I’ve been struggling to find a shampoo that isn’t all chemicals AND can actually clean my scalp. It was nice to read about something that seems so mundane, yet is a part of everyone’s life and can affect them in more ways than one.