Skip to content
Snippets Groups Projects
Commit 959e46f2 authored by Tobias Rico Meinhardt's avatar Tobias Rico Meinhardt
Browse files

added survey functionality

parent a6b7d696
No related branches found
No related tags found
No related merge requests found
......@@ -6,19 +6,23 @@
#define IFTTT_API_KEY "jF1DREiJnO7lXPWoqcyIGb6OpMe8ANPsXBrGeJ6L41B"
#define IFTTT_EVENT_NAME "button_pressed"
#define USERNAME "Tobi"
#define IFTTT_EVENT2_NAME "button_pressed_survey"
#define USERNAME "Tobias Meinhardt"
HTTPClient http; //Declare an object of class HTTPClient
// Buttons on D3 & D4
// Buttons on D3 & D4 & D5
const int button1 = 0;
const int button2 = 2;
const int mode_button = 14;
boolean survey = false;
void setup () {
Serial.begin(115200);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(mode_button, INPUT);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
......@@ -33,16 +37,34 @@ void loop() {
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
int button1Val = digitalRead(button1);
int button2Val = digitalRead(button2);
if (button1Val == LOW) {
// Send POST Request to Webook from IFTTT
// (EVENT, KEY, Value1, Value2, Value3)
int mode_buttonVal = digitalRead(mode_button);
// Send POST Request to Webook from IFTTT
// (EVENT, KEY, Value1, Value2, Value3)
if (button1Val == LOW && !survey) {
send_webhook(IFTTT_EVENT_NAME, IFTTT_API_KEY, "Ich bin anwesend", USERNAME, "");
Serial.println("Sende ich bin anwesend");
}
if (button2Val == LOW) {
if (button2Val == LOW && !survey) {
send_webhook(IFTTT_EVENT_NAME, IFTTT_API_KEY, "Ich muss die Vorlesung verlassen", USERNAME, "");
Serial.println("Sende ich muss gehen");
}
if (button1Val == LOW && survey) {
send_webhook(IFTTT_EVENT2_NAME, IFTTT_API_KEY, "JA", USERNAME, "");
Serial.println("Sende JA");
}
if (button2Val == LOW && survey) {
send_webhook(IFTTT_EVENT2_NAME, IFTTT_API_KEY, "NEIN", USERNAME, "");
Serial.println("Sende NEIN");
}
if (mode_buttonVal == LOW) {
survey = !survey;
Serial.println("Modus geändert");
}
}
delay(100);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment