hello this code shows the motion sensor on the web page. I want to add 1 button, to close the sensor pin. to make the alarm active or passive. how can I do it?
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
//SSID and Password of your Wifi router on mobile phone access point
const char* ssid = "okhan";
const char* password = "atakan2009";
ESP8266WebServer server(80);//Server on port 80
int sensorVal;//Our sensor value as digital input
int sensorPin = 0;//D14/SDA/D4 or D14/SDA
int butonPin = 2 // GPI02
char* securityStatus ="Secure";
int numhits=0;
//This routine runs when you open its IP in browser
void handleRoot(){
char html[1000];
//Build html page refresh every 10 secs
snprintf(html, 1000,
"<html>\
<head>\
<meta http-equiv='refresh' content='10'/>\
<title>Evoto Alarm</title>\
</head>\
<body>\
<center>\
<h1>Evoto Alarm</h1>\
<p>Alarm Durumu: %s</p>\
<p>Sensor Durumu: %d</p>\
</center>\
</body>\
</html>",securityStatus,numhits
);
server.send(200,"text/html",html);//Send web page
}
void setup() {
// put your setup code here, to run once:
pinMode(sensorPin, INPUT);//configure pin 4 as an input
pinMode (butonPin, INPUT);
Serial.begin(115200);
WiFi.begin(ssid,password); //Connect to Wifi router
//Wait for connection
while (WiFi.status() !=WL_CONNECTED){
delay(1000);
Serial.print(".");
}
//If connection successful show IP Address in serial monitor on Arduino
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP Address:");
Serial.println(WiFi.localIP());
server.on("/",handleRoot);
server.begin();//start server
Serial.println("HTTP server started");
}
void loop() {
// put your main code here, to run repeatedly:
//Monitor input from PIR sensor
sensorVal = digitalRead(sensorPin);
if(sensorVal==HIGH){
securityStatus="HAREKET ALGILANDI";
Serial.println("HAREKET ALGILANDI");
numhits++;
}
else{
securityStatus="GUVENLI";
Serial.println("GUVENLI");
}
server.handleClient();//Handle client requests
}