14:03 PM 25 Aug, 2018
  • 0
  • 0
  • 0

To create an accessory to wear that help detect the conditions which may be carcinogenic. we used UV Sensor to detect excess UV lights. Gas sensor also incorporated to detect high smoke. and temperature and heart rate sensors were used to monitor the persons health conditions.

#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 10

const int PulseWire = 0;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0


int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore.
PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float Celcius=0;


void setup()
{
Serial.begin(115200);
pulseSensor.analogInput(PulseWire);   
pulseSensor.setThreshold(Threshold);
sensors.begin(); 
pinMode(A0+2,INPUT); // Gas sensor pin number
pinMode(A0+1,INPUT); // UV sensor pin number
pinMode(11,OUTPUT);// buzzer. 
}


void loop()
{
int myBPM = pulseSensor.getBeatsPerMinute();  // Calls function on our pulseSensor object that returns BPM as an "int".
sensors.requestTemperatures(); 
Celcius=sensors.getTempCByIndex(0);

if (pulseSensor.sawStartOfBeat()) {            // Constantly test to see if "a beat happened". 
 Serial.println("♥  A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
 Serial.print("BPM: ");                        // Print phrase "BPM: " 
 Serial.println(myBPM); // Print the value inside of myBPM. 
}
 if(myBPM > (100)){    // heart rate
  tone(11,262,500);
  delay(500);
  }
 
 if((analogRead(A0+2)) > (400)){  // gas sensor
        tone(11,262,500);
        delay(500);  
}

 if((analogRead(A0+1)) > (800)){  // UV
        tone(11,262,500);
        delay(500);   
}
 if((Celcius) > ( 39 )){
        tone(11,262,500);
        delay(500);
 }   
  delay(20);                    // considered best practice in a simple sketch.

}