// This #include statement was automatically added by the Particle IDE. #include "RCSwitch/RCSwitch.h" RCSwitch mySwitch = RCSwitch(); int inputPin = D3;//Receiver data pin int LED = D7; // Alarm Guard indicator if it is on, then system is guarded. bool alarmstate = false; // alarm is disabled at the beginning //sensor message codes int remoteVal = 0000000; // message from the remote controller (it must be changed) int doorVal = 0000000; // message from the door switch (it must be changed) int pirVal = 0000000; // message from the pir sensor (it must be changed) //sensor message codes //pushingbox// const char * DEVID1 = "v1234567890"; // PushingBox DevId (it must be changed) const char * serverName = "api.pushingbox.com"; // PushingBox API URL TCPClient client; //pushingbox// void setup() { pinMode(inputPin, INPUT_PULLDOWN); mySwitch.enableReceive(inputPin); pinMode(LED, OUTPUT); // sets LED as output digitalWrite(LED, LOW); //alarm led is off delay(1000); } void loop() { if (mySwitch.available()) { float value = mySwitch.getReceivedValue(); if (value == remoteVal){ if(alarmstate == false) {alarmstate = true; digitalWrite(LED, HIGH);} else {alarmstate = false; digitalWrite(LED, LOW);} } if (value == doorVal && alarmstate == true) {sendToPushingBox(DEVID1);} if (value == pirVal && alarmstate == true) {sendToPushingBox(DEVID1);} mySwitch.resetAvailable(); } } void sendToPushingBox(const char * devid) { 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("Connection: close"); client.println(); client.flush(); } }