i keep getting errors when i try to upload code to the uno. heres the code i thought would work.
pushingbox_7_inputs.ino (7.46 KB)
i keep getting errors when i try to upload code to the uno. heres the code i thought would work.
pushingbox_7_inputs.ino (7.46 KB)
I re-typed all the variables that the compiler complained about, and it compiled ok. There may be some dodgy character in the original.
do u have a way to get it uploaded to the uno?
Yes. Retype, or copy/paste, the variables that the compiler complains about. It uploaded fine when I did it.
O i dont know how to do that. Let me google it and figure it out. I wonderened if there was a way to figure it out! Thanks!
This compiles:
////
//
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official)
//
////
#include <SPI.h>
#include <Ethernet.h>
/////////////////
// MODIFY HERE //
/////////////////
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
#define DEVID1 "vCD1F3635179D6F4" //Scenario : "The mailbox is open"
#define DEVID2 "v0725F972F5893B0"
#define DEVID3 "v61BAFD1817543E2"
#define DEVID4 "v23E59D38AF14C9E"
#define DEVID5 "vDF698553B269E75"
#define DEVID6 "xxxxxxxxxxxxxxxx"
#define DEVID7 "xxxxxxxxxxxxxxxx"
//Numeric Pin where you connect your switch
#define pinDevid1 3 // Example : the mailbox switch is connect to the Pin 3
#define pinDevid2 4
#define pinDevid3 5
#define pinDevid4 6
#define pinDevid5 7
#define pinDevid6 8
#define pinDevid7 9
// Debug mode
#define DEBUG true
///////
//End//
///////
char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;
boolean pinDevid2State = false;
boolean pinDevid3state = false;
boolean pinDevid4state = false;
boolean pinDevid5state = false;
boolean pinDevid6state = false;
boolean pinDevid7state = false;
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
Serial.begin(9600);
pinMode(pinDevid1, INPUT);
pinMode(pinDevid2, INPUT);
pinMode(pinDevid3, INPUT);
pinMode(pinDevid4, INPUT);
pinMode(pinDevid5, INPUT);
pinMode(pinDevid6, INPUT);
pinMode(pinDevid7, INPUT);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
else{
Serial.println("Ethernet ready");
}
// give the Ethernet shield a second to initialize:
delay(1000);
}
void loop()
{
////
// Listening for the pinDevid1 state
////
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
{
if(DEBUG){Serial.println("pinDevid1 is HIGH");}
pinDevid1State = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID1);
}
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
{
if(DEBUG){Serial.println("pinDevid1 is LOW");}
pinDevid1State = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID1);
}
////
// Listening for the pinDevid2 state
////
if (digitalRead(pinDevid2) == HIGH && pinDevid2State == false) // switch on pinDevid2 is ON
{
if(DEBUG){Serial.println("pinDevid2 is HIGH");}
pinDevid2State = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID2);
}
if (digitalRead(pinDevid2) == LOW && pinDevid2State == true) // switch on pinDevid2 is OFF
{
if(DEBUG){Serial.println("pinDevid2 is LOW");}
pinDevid2State = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID2);
}
////
// Listening for the pinDevid3 state
////
if (digitalRead(pinDevid3) == HIGH && pinDevid3state == false) // switch on pinDevid3 is ON
{
if(DEBUG){Serial.println("pinDevid3 is HIGH");}
pinDevid3state = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID3);
}
if (digitalRead(pinDevid3) == LOW && pinDevid3state == true) // switch on pinDevid3 is OFF
{
if(DEBUG){Serial.println("pinDevid3 is LOW");}
pinDevid3state = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID3);
}
////
// Listening for the pinDevid4 state
////
if (digitalRead(pinDevid4) == HIGH && pinDevid4state == false) // switch on pinDevid4 is ON
{
if(DEBUG){Serial.println("pinDevid4 is HIGH");}
pinDevid4state = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID4);
}
if (digitalRead(pinDevid4) == LOW && pinDevid4state == true) // switch on pinDevid4 is OFF
{
if(DEBUG){Serial.println("pinDevid4 is LOW");}
pinDevid4state = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID4);
}
////
// Listening for the pinDevid5 state
////
if (digitalRead(pinDevid5) == HIGH && pinDevid5state == false) // switch on pinDevid5 is ON
{
if(DEBUG){Serial.println("pinDevid5 is HIGH");}
pinDevid5state = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID5);
}
if (digitalRead(pinDevid5) == LOW && pinDevid5state == true) // switch on pinDevid5 is OFF
{
if(DEBUG){Serial.println("pinDevid5 is LOW");}
pinDevid5state = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID5);
}
////
// Listening for the pinDevid6 state
////
if (digitalRead(pinDevid6) == HIGH && pinDevid6state == false) // switch on pinDevid6 is ON
{
if(DEBUG){Serial.println("pinDevid6 is HIGH");}
pinDevid6state = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID6);
}
if (digitalRead(pinDevid6) == LOW && pinDevid6state == true) // switch on pinDevid6 is OFF
{
if(DEBUG){Serial.println("pinDevid6 is LOW");}
pinDevid6state = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID6);
}
////
// Listening for the pinDevid7 state
////
if (digitalRead(pinDevid7) == HIGH && pinDevid7state == false) // switch on pinDevid7 is ON
{
if(DEBUG){Serial.println("pinDevid7 is HIGH");}
pinDevid7state = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID7);
}
if (digitalRead(pinDevid7) == LOW && pinDevid7state == true) // switch on pinDevid7 is OFF
{
if(DEBUG){Serial.println("pinDevid7 is LOW");}
pinDevid7state = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID7);
}
}
//Function for sending the request to PushingBox
void sendToPushingBox(String devid){
if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) {
if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");}
client.print("GET /pushingbox?devid=");
client.print(devid);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(serverName);
client.println("User-Agent: Arduino");
client.println();
}
else {
if(DEBUG){Serial.println("connection failed");}
}
// if there are incoming bytes available
// from the server, read them and print them:
if(DEBUG){
if (client.available()) {
char c = client.read();
Serial.print(c);
}
}
if(DEBUG){Serial.println();}
if(DEBUG){Serial.println("disconnecting.");}
client.stop();
}
Awesome man thanks alot! Im still learning but i got a long ways to go!
thanks again! that worked for what i needed!!
this will add 7 inputs for the pushingbox api.
it will send alerts to ur iphone from pushingbox with a set of contact closure.
please change the devid for ur unique id from pushingbox.