const int pirPin1 = 13; // Sensor PIR 1 terhubung ke pin digital 12
const int pirPin2 = 12; // Sensor PIR 2 terhubung ke pin digital 13
int count = 0; // Jumlah orang dalam ruangan
int suhu = 25; // Suhu default
bool motionDetected1 = false; // Status deteksi gerakan sensor 1
bool motionDetected2 = false; // Status deteksi gerakan sensor 2
void setup() {
Serial.begin(9600);
pinMode(pirPin1, INPUT);
pinMode(pirPin2, INPUT);
}
void loop() {
int motion1 = digitalRead(pirPin1);
int motion2 = digitalRead(pirPin2);
if (motion1 == HIGH && !motionDetected1 && !motionDetected2) {
count++;
suhu--;
motionDetected1 = true;
updateDisplay();
delay(1);
}
if (motion2 == HIGH && !motionDetected2 && !motionDetected1) {
count--;
suhu++;
motionDetected2 = true;
updateDisplay();
delay(1);
}
if (motion1 == LOW) {
motionDetected1 = false;
}
if (motion2 == LOW) {
motionDetected2 = false;
}
}
void updateDisplay() {
Serial.println("Jumlah Orang: " + String(count));
Serial.println("Set suhu: " + String(suhu));
// Perbarui tampilan LCD atau lakukan tindakan lain yang diinginkan
}