hello i am newbie programmer arduino. i make project with mlx90614 with the condition :
condition 1 : make range 27C to 37C for normal temperature
condition 2 : if higher 37C for not normal temperature
condition 3 ; if less 27C show the text ("name device") / off mlx and show the text ("name device")
i make this code like this but i know this not flexible and efficient Can anyone help me? thank you
code i make :
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Adafruit_MLX90614.h>
#define I2C_ADDR 0x27 //I2C adress, you should use the code to scan the adress first (0x27) here
#define BACKLIGHT_PIN 3 // Declaring LCD Pins
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define laser 23
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
void setup() {
Serial.println("Temperature Sensor MLX90614");
pinMode(laser, OUTPUT); // Connect LASER
digitalWrite(laser, LOW);
mlx.begin();
lcd.begin (16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH); //Lighting backlight
lcd.home ();
}
void loop() {
delay(1000);
lcd.clear();
lcd.setCursor(3,0);
lcd.print("Non-contact");
lcd.setCursor(2,1);
lcd.print("Suhu: ");
lcd.print(mlx.readObjectTempC());
lcd.print("C ");
delay(2000);
if(mlx.readObjectTempC() <= 37 and (mlx.readObjectTempC() >= 27)){
digitalWrite(laser, HIGH);
lcd.clear();
lcd.setCursor(1,0);
delay(500);
lcd.print("Suhu Tubuh Anda");
lcd.setCursor(5,1);
lcd.print("Normal");
delay(2000);}
else if (mlx.readObjectTempC() >= 37){
digitalWrite(laser, HIGH);
lcd.clear();
lcd.setCursor(1,0);
delay(500);
lcd.print("Suhu Tubuh Anda");
lcd.setCursor(2,1);
lcd.print("Tidak Normal");
delay(2000);}
else if (mlx.readObjectTempC() <= 25){
digitalWrite(laser, LOW);
lcd.clear();
lcd.setCursor(2,0);
delay(500);
lcd.print("auto WITEZER");
lcd.setCursor(5,1);
lcd.print("ONLINE");
delay(2000);}
}