/* Send-a-Tweet Based on kid-summoner.ino by Jen Looper Additions and edits by Anouska de Graaf - www.anouskadegraaf.nl */ int val1 = 0; //variable for push-button status scenario 1 int val2 = 0; //variable for push-button status scenario 2 int state = 1; //variable for on/off state const char * SAT1 = "DEVICE_ID1"; // Send-a-Tweet scenario 1 - Change DEVICE_ID1 with your Device ID!!! const char * SAT2 = "DEVICE_ID2"; // Send-a-Tweet scenario 2 - Change DEVICE_ID2 with your Device ID!!! const char * DEVID = ""; const char * serverName = "api.pushingbox.com"; // Pushingbox API URL TCPClient client; void setup() { pinMode(D1, INPUT); pinMode(D2, INPUT); Serial.begin(9600); Serial.println("Serial open"); } void loop() { val1 = digitalRead(D1); //read the state of the push-button val2 = digitalRead(D2); if (val1 == LOW) { //if push-button pressed DEVID = SAT1; state = !state; //reverse on/off state delay(250); //primitive button debounce Serial.println("button scenario1 pushed!"); sendToPushingBox(DEVID); } else if (val2 == LOW) { //if push-button pressed DEVID = SAT2; state = !state; //reverse on/off state delay(250); //primitive button debounce Serial.println("button scenario2 pushed!"); sendToPushingBox(DEVID); } } void sendToPushingBox(const char * devid) { Serial.println("Start sendToPushingBox"); client.stop(); if (client.connect(serverName, 80)) { client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Spark"); client.println(); client.flush(); } else{ Serial.println("connection failed"); } }