1#include <Wire.h>
2#include <LiquidCrystal_I2C.h>
3#include <Adafruit_MLX90614.h>
4#include <Servo.h>
5
6Adafruit_MLX90614 mlx = Adafruit_MLX90614();
7LiquidCrystal_I2C lcd(0x27,16,2);
8
9Servo myservo;
10Servo myservo2;
11
12unsigned long previousMillis = 0;
13unsigned long elapsedMillis = 0;
14
15int pos ;
16int ledState = LOW;
17int debounceTime = 100;
18
19void setup()
20{
21 mlx.begin();
22 lcd.init();
23 lcd.backlight();
24 myservo.attach(4);
25 myservo2.attach(5);
26 pinMode(9, INPUT);
27
28 lcd.setCursor(1,0);
29 lcd.print("Hello Everyone");
30 lcd.setCursor(1,1);
31 lcd.print("Loading. . . . .");
32 delay(2000);
33 lcd.clear();
34
35}
36
37
38void loop()
39{
40 Handsanit();
41}
42
43void Handsanit(){
44 elapsedMillis = millis() - previousMillis;
45 if(digitalRead(9) == LOW && elapsedMillis > debounceTime){
46 if(ledState == HIGH){
47 ledState = LOW;
48 lcd.setCursor(1,0);
49 if(mlx.readObjectTempC()>37){
50 delay(100);
51 lcd.print("suhu anda tinggi!!");
52 }
53 lcd.print(" NonContact ");
54 lcd.setCursor(2,1);
55 lcd.print("Suhu: ");
56 lcd.print(mlx.readObjectTempC()+2.2);
57 lcd.print("C ");
58 delay(500);
59 for (pos = 0; pos <= 180; pos += 1) {
60
61 myservo.write(pos);
62 myservo2.write(pos);
63 delay(15);
64 }
65 for (pos = 40; pos >= 0; pos -= 1) {
66 myservo.write(pos);
67
68 myservo2.write(pos);
69 delay(15);
70 }
71 }else{
72 for ( ;pos <= 80; pos += 1)
73 {
74 myservo.write(pos);
75 myservo2.write(pos);
76 delay(5);
77 }
78 ledState = HIGH;
79 lcd.setCursor(1,0);
80 if(mlx.readObjectTempC()>37){
81 delay(1000);
82 lcd.print("Suhu Anda Tinggi!!");
83 }
84 lcd.print(" NonContact ");
85 lcd.setCursor(2,1);
86 lcd.print("Suhu: ");
87 lcd.print(mlx.readObjectTempC()+2.2);
88 lcd.print("C ");
89 delay(500);
90 }
91 previousMillis = millis();
92 }
93}<br>