Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (31 sloc) 783 Bytes
#include <Arduino.h>
#include "ESP8266WiFi.h"
const char* ssid = "<SSID>";
const char* password = "<PWD>";
WiFiServer wifiServer(80);
char Response[] = {'B','T','N'};
void btnPress();
void setup() {
Serial.begin(115200);
delay(1000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting..");
}
Serial.print("Connected to WiFi. IP:");
Serial.println(WiFi.localIP());
wifiServer.begin();
pinMode(0, INPUT_PULLUP);
attachInterrupt(0, btnPress, FALLING);
}
void loop(){}
int lmillis = 0;
void btnPress() {
if(lmillis == 0 || millis()-lmillis > 100){
WiFiClient client = wifiServer.available();
client.write(Response);
Serial.println("BTN-PRESSED");
lmillis=millis();
}
}
You can’t perform that action at this time.