/* Send-a-Tweet Based on kid-summoner.ino by Jen Looper Additions and edits by Anouska de Graaf - www.anouskadegraaf.nl Additions and edits by Maged - www.cairohackerspace.org */ int val1 = 0; //variable for push-button status scenario 1 int state = 1; //variable for on/off state const char * DEVID = "v7DA61F8C49BE992"; // outlet_state - Change DEVICE_ID1 with your Device ID!!! const char * serverName = "[api.pushingbox.com](http://api.pushingbox.com)"; // Pushingbox API URL TCPClient client; void setup() { pinMode(D1, INPUT); Serial.begin(9600); Serial.println("Serial open"); } void loop() { val1 = digitalRead(D1); //read the state of the limit switch if (val1 == LOW) { //if limit switch pressed state = !state; //reverse on/off state delay(250); //primitive debounce Serial.println("Activated!"); 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"); } }