Pages: [1]   Go Down
Author Topic: PushingBox Hilfe Anfänger LED zur kontrolle einschalten  (Read 429 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo
Ich wollte mir zuerst eine email von Arduino schicken lassen aber da bin ich nicht zurechtgekommen.
Jetzt habe ich das PushingBox gefunden ,und schon die erst Nachricht auf das Handy bekommen  smiley-grin
Es soll mir dann von einem Bewegungsmelder auf Pin5 eine Nachricht auf mein HANDY geschickt werden ,und als kontrolle eine LED auf Pin3 eingeschaltet werden.

jetzt habe ich aber einige Fragen :

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 5; // Example : the mailbox switch is connect to the Pin 5

1. was bedeutet uint8_t ????  pinDevid1 ist mir klar.
2. ich würde gerne eine LED am pin D3 auf HIGH stellen wenn Pin 5 auf HIGH ist . Bekomme das nicht hin .
    habe schon den ganzen Tag versucht keine ahnung wo ich das reinschreiben soll .
3. würde gerne die IP Adresse 192.168.1.177 bekommen aber da stimmt auch was nicht ?

Ich hoffe es kann mir bitte jemand helfen !!!!!!!!!!!!!



Code:
////
//
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2
//
////

#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
IPAddress ip(192,168,1,177);
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
char DEVID1[] = "Your_DevID_Here"; //Scenario : "The mailbox is open"

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 5; // Example : the mailbox switch is connect to the Pin 5

// Debug mode
boolean DEBUG = true;
  //////////////
 // End //
//////////////


char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop


// 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);
 
  // 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");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // 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); //Here you can run an other scenario by creating a DEVID2 variable
      }
     
     
      //DEBUG part
      // this write the respons from PushingBox Server.
      // You should see a "200 OK"
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
     
      // if there's no net connection, but there was one last time
      // through the loop, then stop the client:
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}


//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
  client.stop();
  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");}
  }
}



Danke
Logged

Offline Offline
Faraday Member
**
Karma: 97
Posts: 3507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1. uint8_t ist eine system-unabhängige Schreibweise für "byte": unsigned integer 8 bit

2. digitalwrite(3, digitalRead(5));

Vorher noch in setup() die Pins mit pinMode richtig konfigurieren
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Danke werde ich am Wochenende gleich mal versuchen !

ich muss doch auch am Anfang das machen oder ?

const int ledPin = 3;      // the number of the LED pin

im Setup

  pinMode(ledPin, OUTPUT);

und dann ?

digitalwrite(3, digitalRead(5));  gehört digitalwrite nicht digitalWrite ?

sorry aber komm da nicht ganz mit.

Vielleicht hast ja noch mal Zeit mir das zu erklären.

Danke Serenifly
« Last Edit: September 14, 2013, 09:40:37 am by pepeAUT » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Habe das jetzt so gemacht :

Quote
////
//
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2
//
////

#include <SPI.h>
#include <Ethernet.h>

const int ledPin =  3;  // LED ist auf pin 3

  /////////////////
 // MODIFY HERE //
/////////////////
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
IPAddress ip(192,168,1,177);
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
char DEVID1[] = "---------- "; //Scenario : "The mailbox is open"

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 5; // Example : the mailbox switch is connect to the Pin 5

// Debug mode
boolean DEBUG = true;
  //////////////
 // End //
//////////////


char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop


// 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(ledPin, OUTPUT); // LED als Ausgang
  // 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");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // 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");
        digitalWrite(ledPin, HIGH); } // LED einschalten
        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");
        digitalWrite(ledPin, LOW); }// LED ausschalten
        pinDevid1State = false;
        //Sending request to PushingBox when the pin is LOW
        //sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable
      }
     
     
      //DEBUG part
      // this write the respons from PushingBox Server.
      // You should see a "200 OK"
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
     
      // if there's no net connection, but there was one last time
      // through the loop, then stop the client:
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}


//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
  client.stop();
  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");}
  }
}

lg
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hallo
kann mir bitte jemand sagen was ich ändern muss damit ich meine eigene Ip verwenden kann ??

Habe das am Anfang
IPAddress ip(192,168,1,177);


habe schon vieles versucht aber bekomme immer eine zugewiesen mit DHCP

verstehe das irgendwie nicht :

   if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

was muss ich ändern

Danke
Logged

Pages: [1]   Go Up
Jump to: