Professional Documents
Culture Documents
h>
#define OLED_Address 0x3C // 0x3C device address of I2C OLED. Few other OLED has 0x3D
Adafruit_SSD1306 oled(128, 64); // create our screen object setting resolution to 128x64
#include <Adafruit_MLX90614.h>
#define buzzer 2
int a = 0;
int lasta = 0;
int lastb = 0;
int LastTime = 0;
int ThisTime;
int BPM = 0;
//Adafruit_SSD1306 display(OLED_RESET);
float Xsuhu_ruangan ; \
float Xsuhu_tubuh ;
int XBPMval ;
int z = 0;
void setup() {
Serial.begin(9600);
pinMode(3, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
Wire.begin();
mlx.begin();
oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address);
oled.clearDisplay();
oled.setTextSize(2);
void loop()
suhu_ruangan = mlx.readAmbientTempC();
suhu_tubuh = mlx.readObjectTempC();
if (millis() > time_1 + INTERVAL_MESSAGE1) {
time_1 = millis();
if (a > 127)
oled.clearDisplay();
a = 0;
lasta = a;
ThisTime = millis();
oled.setTextColor(WHITE);
lastb = b;
lasta = a;
if (BeatComplete)
BPMTiming = false;
BeatComplete = false;
if (BPMTiming == false)
LastTime = millis();
BPMTiming = true;
BeatComplete = true;
oled.setCursor(0, 50);
oled.print("BPM:");
oled.print(BPM);
oled.display();
a++;
}
if (z > 10 && z <= 20 && hold == false)
oled.clearDisplay();
oled.setTextColor(WHITE);
oled.setTextSize(2);
oled.setCursor(30, 35);
oled.print(suhu_tubuh);
oled.print(" C");
oled.setTextSize(2);
oled.setCursor(0, 2);
oled.print("Suhu : ");
if (hold == true)
oled.clearDisplay();
oled.setTextColor(WHITE);
oled.setTextSize(2);
oled.setCursor(15, 2);
oled.setCursor(0, 25);
oled.print(Xsuhu_tubuh);
oled.print(" C");
oled.setCursor(0, 35);
oled.print(XBPMval);
oled.print(" BPM");
oled.display();
time_2 = millis();
z++;
if (z > 20)
oled.clearDisplay();
z = 0;
if (digitalRead(3) == 0)
digitalWrite(buzzer, HIGH);
delay(75);
digitalWrite(buzzer, LOW);
z = 0;
oled.clearDisplay();
Xsuhu_ruangan = suhu_ruangan;
Xsuhu_tubuh = suhu_tubuh;
XBPMval = BPM;
hold = !hold;
Serial.print("BPM : ");
Serial.print(BPM);
Serial.print(suhu_ruangan);
Serial.print(suhu_tubuh);
Serial.print(" *C");
Serial.print('\t');
Serial.print(z);
Serial.println('\t');