0% found this document useful (0 votes)
12 views4 pages

KitaNet Project3

The document contains code for a flame sensor function that reads the state of a fire sensor, triggers an alarm if it detects a fire by activating a buzzer, turning on an LED, and closing a relay. It also contains code for a manual button function that reads the state of a manual button, detects when it is pressed and released, and triggers an alarm if the button is held for over 7 seconds by activating a buzzer and LED in a flashing pattern. The code controls the activation of sensors, alarms, and LEDs in response to the fire sensor and manual button.

Uploaded by

andrevans919
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

KitaNet Project3

The document contains code for a flame sensor function that reads the state of a fire sensor, triggers an alarm if it detects a fire by activating a buzzer, turning on an LED, and closing a relay. It also contains code for a manual button function that reads the state of a manual button, detects when it is pressed and released, and triggers an alarm if the button is held for over 7 seconds by activating a buzzer and LED in a flashing pattern. The code controls the activation of sensors, alarms, and LEDs in response to the fire sensor and manual button.

Uploaded by

andrevans919
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

void flameSensor()

int isButtonPressed = digitalRead(fireSensor);

if (isButtonPressed==LOW && statusPress==0){

//Serial.println("Fire DETECTED");

statusPress=1;

if(statusPress==1)

tone(buzzer, 1000, 500);

digitalWrite(relay,LOW);

Blynk.setProperty(V7, "color", BLYNK_RED);

Blynk.setProperty(V7, "label", "DETECTED");

else if(isButtonPressed==HIGH)

//Serial.println("AMAN");

digitalWrite(relay,HIGH);

statusPress=0;

Blynk.setProperty(V7, "label", "SAFE");

Blynk.virtualWrite(V7,!isButtonPressed);

}
void manualButtonStatus()

int reading = digitalRead(manualButton);

if (reading != lastButtonState)

lastDebounceTime = millis();

if ((millis() - lastDebounceTime) > debounceDelay)

if (reading != buttonState)

buttonState = reading;

// Saat Tombol di tekan

if (buttonState == 0 && flag2 == 0)

presstime = millis();

flag1 = 0;

flag2 = 1;

tapCounter++;

buzzerAlert(500);

// Saat Tombol dilepas

if (buttonState == 1 && flag1 == 0)


{

releasetime = millis();

flag1 = 1;

flag2 = 0;

timediff = releasetime - presstime;

if ((millis() - presstime) > 800 && buttonState == 1)

if (tapCounter == 1)

// Estimasi 7 detik

if (timediff >=7000)

modeButton=1;

if(modeButton==1)

for(int i=0;i<6;i++)

buzzerAlert(500);

digitalWrite(alarmLed, HIGH);

delay(200);

buzzerAlert(500);

digitalWrite(alarmLed, LOW);

delay(200);

modeButton=0;

}
//Serial.println("Alarm Door dan PIR OFF");

toggleSwitch=0;

pilih=0;

digitalWrite(buzzer,toggleSwitch);

digitalWrite(buzzer,pilih);

digitalWrite(alarmLed,!toggleSwitch);

digitalWrite(alarmLed,!pilih);

You might also like