Sie sind auf Seite 1von 5

//================VARIABEL GSM=======================//

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11);

//========================================= library lcd


============================================//

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F,16,2);

#include <LiquidCrystal_I2C.h>

//========================================= library suhu


============================================//

#include <OneWire.h>

#include <DallasTemperature.h>

#define ONE_WIRE_BUS 8

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

float Celcius = 0;

//========================================= variabel BPM


===========================================//

unsigned long waktu0,waktuBPM,waktuawal,waktusekarang,waktusuhu,resetwaktusuhu=0;

float pengubahan,tes,reff=0;

unsigned int bpm1,hold,bpm2=0;

int dataADC,x;

void setup() {

lcd.begin();

sensors.begin();

pinMode(6, INPUT); // Setup for leads off detection LO +

pinMode(7, INPUT); // Setup for leads off detection LO -

Serial.begin(9600);

//========================================= program suhu


===========================================//

void SUHU(){

sensors.requestTemperatures();
Celcius = sensors.getTempCByIndex(0);

lcd.setCursor(7,0);

lcd.print(Celcius);

//========================================= program BPM


===========================================//

void ECG(){

//----------PEMBACAAN OUTPUT------------

dataADC = analogRead(1);

Serial.println(dataADC);

//------------PEMBACAAN BPM PALSU---------

if (reff<=dataADC)

reff=dataADC;

else

hold=1;

reff=reff;

tes=(reff*0.7);

if ((dataADC<=tes)&&(hold=1))

bpm1++;

hold=0;

reff=0;

lcd.setCursor(15,1);

lcd.print(" ");

lcd.setCursor(14,1);

lcd.print(bpm1);

lcd.setCursor(8,1);

lcd.print(" ");
delay(1);

//------- PEMBACAAN WAKTU---------

waktu0=millis()-waktuBPM;

if (waktu0>=10000)

bpm2=bpm1*6;

bpm1=0;

waktuBPM=millis();

lcd.setCursor(5,1);

lcd.print(bpm2);

delay(1);

if(bpm2>100)

SendMessage1();

delay(1000);

if(bpm2<60)

SendMessage2();

delay(1000);

//========================================= program GSM


===========================================//

void SendMessage1()

mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode

delay(1000); // Delay of 1000 milli seconds or 1 second

mySerial.println("AT+CMGS=\"+6281327474563\"\r"); // Replace x with mobile number


delay(1000);

mySerial.println("TAKIKARDIA");// The SMS text you want to send

delay(100);

mySerial.println((char)26);// ASCII code of CTRL+Z

delay(1000);

void SendMessage2()

mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode

delay(1000); // Delay of 1000 milli seconds or 1 second

mySerial.println("AT+CMGS=\"+6281327474563\"\r"); // Replace x with mobile number

delay(1000);

mySerial.println("BRADIKARDIA");// The SMS text you want to send

delay(100);

mySerial.println((char)26);// ASCII code of CTRL+Z

delay(1000);

void loop()

if((digitalRead(6) == 1)||(digitalRead(7) == 1))

Serial.println('!');//Serial Plotter akan berhenti jika tidak ada input

else

lcd.setCursor(0,0);

lcd.print("SUHU :");

lcd.setCursor(15, 0);

lcd.print("C");

lcd.setCursor(14, 0);

lcd.print(char(223));

lcd.setCursor(0, 1);
lcd.print("BPM :");

waktusuhu=millis()-resetwaktusuhu;

if(waktusuhu>15000)

SUHU();

resetwaktusuhu=millis();

ECG();

Das könnte Ihnen auch gefallen