Close
0%
0%

Arduino Dead or Alive

Trick for Treat .. Have a Heart

Similar projects worth following

Trick for treat .. the illusion of proving you are alive .. and alive enough to even enjoy a treat.

This particular project is a carry over from a request to simply 3D print a heart for a 4th grade class demonstration -- and after negotiations negated instead reanimating a heart in a lightening storm .. uh, with an Arduino obviously .. we (me) pitched a pulse driven beating heart .. that in turn rewards your having proved to subsist, with a treat.

Ingredients
Arduino Uno
Servo
(2) 10K Potentiometer
LCD Display
Pulse Sensor
(2) 330 ohm Resistor
1000uf  Capacitor
Piezo Buzzer
2N2222 Transistor
4007 Diode
Neopixels
(2) Toggle Switch
MDF

Notations
1. 'Clear watermelon' filament .. (>_ლ)
2. Censored #$@*!$#% about people, places and things.
3. Extensive modification of https://3dwarehouse.sketchup.com/model/ufce9d3ab-1e98-442f-afb3-7ed2d09802dd/heart by Profesor D.
4. Did not earn a TVShow episode bcz .. it had been done.
5. Original concept included a candy dispenser that required evidence of life.

Archive
https://hackaday.io/project/161614-arduino-dead-or-alive
https://3dwarehouse.sketchup.com/model/ufce9d3ab-1e98-442f-afb3-7ed2d09802dd/heart
https://www.thingiverse.com/thing:3186600
http://vijemiller.com/index.php?entry=entry181108-110913


SSEYO Koan Play File - 2.58 MB - 10/31/2018 at 00:35

Download

Standard Tesselated Geometry - 723.81 kB - 10/31/2018 at 00:34

Download

  • Boo .. lean. Not here.

    Vije Miller10/31/2018 at 00:44 0 comments

    // Arduino Dead or Alive
    // Vije Miller
    
    #include <FastLED.h>
    #include <LiquidCrystal.h>
    #include <Servo.h>
    
    #define NUM_LEDS 5
    CRGB leds[NUM_LEDS];
    #define PIN 6
    
    // Beat Var LED
    int bpm_led_delay = 500;
    
    // Buzzer Pin
    const int ekg = 9;
    
    // LCD
    const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
    LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
    
    // Switch
    int aux = 7;
    int aux_state = 0;
    
    // Servo
    Servo srv;
    int st = 110;
    int ps = 45;
    
    // Pulse
    int pulse = A0
                int val;
    int tot;
    int nxt;
    int high;
    
    void setup()
    {
      Serial.begin(9600);
    
      FastLED.addLeds<WS2812, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
    
      pinMode(ekg, OUTPUT);
      digitalWrite(ekg, LOW);
    
      pinMode(aux, INPUT);
    
      srv.attach(10);
      srv.write(st);
    
      lcd.begin(16, 2);
      lcd.setCursor(0, 0);
      lcd.print("Dead or Alive?");
    
    }
    
    void loop() {
      // Motor and Buzzer Switch On/Off
      aux_state = digitalRead(aux);
    
      // Reset Value
      tot = 0;
      nxt = 0;
      set_bpm = 0;
    
      // Smoothing Pulse
      for (int n = 0; n <= 5; n++) {
        for (int i = 0; i <= 25; i++) {
          val = analogRead(pulse);
          tot = val + tot;
          // Display Per Peak
          if (val > 580) { // Adjust
            // If Motor and Buzzer
            if (aux_state == HIGH) {
              beat_led(0xff, 0x00, 0x00);
              delay(bpm_led_delay);
              // If No Motor and Buzzer
            } else if (aux_state == LOW) {
              beat_led_non(0xff, 0x00, 0x00);
              delay(bpm_led_delay);
            }
          }
          delay(2);
        }
        nxt = tot / 25;
        set_bpm = set_bpm + nxt;
      }
      // BPM Maths
      bpm = set_bpm * 12;
      // Not Very Accurate .. Meh!
    
      if (bpm > 30) {
        lcd.setCursor(0, 0);
        lcd.print("Alive!");
        lcd.setCursor(0, 1);
        lcd.print(bpm);
        lcd.print(" BPM");
      } else if (bpm <= 30) {
        lcd.setCursor(0, 0);
        lcd.print("Undead!");
      }
    
    }
    
    
    // Neopixel FastLED Fade Red via http://tweaking4all.com
    void beat_led(byte red, byte green, byte blue) {
      float r, g, b;
      for (int k = 0; k < 256; k = k + 8) {
        r = (k / 256.0) * red;
        g = (k / 256.0) * green;
        b = (k / 256.0) * blue;
        setAll(r, g, b);
        showStrip();
        digitalWrite(ekg, HIGH);
        srv.write(ps);
      }
      digitalWrite(ekg, LOW);
      srv.write(st);
      for (int k = 255; k >= 0; k = k - 10) {
        r = (k / 256.0) * red;
        g = (k / 256.0) * green;
        b = (k / 256.0) * blue;
        setAll(r, g, b);
        showStrip();
      }
    }
    
    void beat_led_non(byte red, byte green, byte blue) {
      float r, g, b;
      for (int k = 0; k < 256; k = k + 8) {
        r = (k / 256.0) * red;
        g = (k / 256.0) * green;
        b = (k / 256.0) * blue;
        setAll(r, g, b);
        showStrip();
      }
      for (int k = 255; k >= 0; k = k - 10) {
        r = (k / 256.0) * red;
        g = (k / 256.0) * green;
        b = (k / 256.0) * blue;
        setAll(r, g, b);
        showStrip();
      }
    }
    
    void showStrip() {
    #ifdef ADAFRUIT_NEOPIXEL_H
      strip.show();
    #endif
    #ifndef ADAFRUIT_NEOPIXEL_H
      FastLED.show();
    #endif
    }
    
    void setPixel(int Pixel, byte red, byte green, byte blue) {
    #ifdef ADAFRUIT_NEOPIXEL_H
      strip.setPixelColor(Pixel, strip.Color(red, green, blue));
    #endif
    #ifndef ADAFRUIT_NEOPIXEL_H
      leds[Pixel].r = red;
      leds[Pixel].g = green;
      leds[Pixel].b = blue;
    #endif
    }
    
    void setAll(byte red, byte green, byte blue) {
      for (int i = 0; i < NUM_LEDS; i++ ) {
        setPixel(i, red, green, blue);
      }
      showStrip();
    }

  • Ardnotomy

    Vije Miller10/26/2018 at 05:44 0 comments

  • In Case You Didn't Notice ..

    Vije Miller10/21/2018 at 01:12 0 comments

  • If I Only Had A ...

    Vije Miller10/17/2018 at 19:12 0 comments

View all 4 project logs

  • 1
    Step 1
  • 2
    Tear Your Heart Out
  • 3
    Step 3

View all 3 instructions

Enjoy this project?

Share

Discussions

terrag wrote 11/08/2018 at 20:35 point

Great looking project, and slick demo video! I see that you have a servo included in the schematic. I scanned your arduino code but didn't see any command to tell it to move. Looks like it is not doing anything yet, what did you have planned? Maybe it would be fun to glue a vibration motor close to the heartbeat sensor to give some sensory feedback?

  Are you sure? yes | no

Vije Miller wrote 11/08/2018 at 21:50 point

There IS a servo actions in the code and the toggle deactivates both it and the piezo .. how ever .. upon operation it was too 'clattery' (plastic on plastic) and by the dead line I had not been able to properly reduce the noise so .. it is not active in the video.

  Are you sure? yes | no

Vije Miller wrote 11/08/2018 at 21:51 point

srv.write(ps);

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates