Permalink
Browse files

added option today or tomorrow

  • Loading branch information...
1 parent 526b674 commit 9569a674e1db5e61a3769916fd83dafcd88fcda3 @dillenburg committed Oct 30, 2011
Showing with 105 additions and 79 deletions.
  1. +105 −79 wetterhaus.ino
View
184 wetterhaus.ino
@@ -21,6 +21,7 @@ char muster[4][6] ={
char temp_zahl[3];
int regenwahrscheinlickeit = 0;
+int tag = 1; // 0 = heute 1 = morgen
int nr_zeichen = 0;
int nr_muster = 0;
int ausgabe = 0;
@@ -41,71 +42,105 @@ Servo myservo;
void suche_muster()
{
//Hilffunktion zum füllen der Variable für die Regenwahrscheinlichkeit
- char c = client.read();
- if( c == muster[nr_muster][nr_zeichen]) // Muster zeichenweise vergleichen
- {
- if (nr_zeichen < 5 )
- {nr_zeichen++;}
- else // Muster gefunden
- {
- if (debug_on) {Serial.print("Muster gefunden ");Serial.print(nr_muster);}
- ausgabe++;
- nr_zeichen =0;
- nr_muster++;
-
- }
-
- }
- else
+
+ if (client.connect(server, 80)) {
+ Serial.println("connected ");
+ Serial.println(tag);
+ // Make a HTTP request:
+ switch(tag)
{
- nr_zeichen=0;
+ case 0:
+ client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-aktuell.html");
+ break;
+ case 1:
+ client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-morgen.html");
+ break;
+ default:
+ client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-morgen.html");
+ break;
}
- if (ausgabe == 2)
+
+ client.println();
+ }
+ else {
+ // kf you didn't get a connection to the server:
+ Serial.println("connection failed");
+ }
+ while(client.available() && ausgabe < 7)
{
- if (debug_on) Serial.print(c);
- switch (c) {
- case '1':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '2':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '3':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '4':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '5':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '6':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '7':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '8':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '9':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
- case '0':
- temp_zahl[zaehler] = c;
- zaehler++;
- break;
+ char c = client.read();
+ if( c == muster[nr_muster][nr_zeichen]) // Muster zeichenweise vergleichen
+ {
+ if (nr_zeichen < 5 )
+ {nr_zeichen++;}
+ else // Muster gefunden
+ {
+ if (debug_on) {Serial.print("Muster gefunden ");Serial.print(nr_muster);}
+ ausgabe++;
+ nr_zeichen =0;
+ nr_muster++;
+
+ }
+
+ }
+ else
+ {
+ nr_zeichen=0;
}
+ if (ausgabe == 2)
+ {
+ if (debug_on) Serial.print(c);
+ switch (c) {
+ case '1':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '2':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '3':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '4':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '5':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '6':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '7':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '8':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '9':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ case '0':
+ temp_zahl[zaehler] = c;
+ zaehler++;
+ break;
+ } // end Case
+
+ } //
+ } // end while loop
+ if (ausgabe==3)
+ {
+ ausgabe = 9;
+ int regen = atoi(temp_zahl);
+ myservo.write(map(regen,0,100,150,30));
}
}
@@ -114,7 +149,11 @@ void suche_muster()
void setup() {
// start the serial library:
Serial.begin(57600);
+ pinMode(5, OUTPUT);
+ pinMode(6, INPUT);
+ digitalWrite(5, HIGH);
myservo.attach(9);
+ myservo.write(90);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
@@ -127,16 +166,7 @@ void setup() {
Serial.println("connecting...");
// if you get a connection, report back via serial:
- if (client.connect(server, 80)) {
- Serial.println("connected");
- // Make a HTTP request:
- client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-morgen.html");
- client.println();
- }
- else {
- // kf you didn't get a connection to the server:
- Serial.println("connection failed");
- }
+
}
// ------------------ Hauptprogramm ---------------------------------------
@@ -145,23 +175,19 @@ void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
- if (client.available() && ausgabe < 7) { suche_muster(); }
- if (ausgabe==3)
- {
-
- ausgabe = 9;
- int regen = atoi(temp_zahl);
- myservo.write(map(regen,0,100,150,30));
- }
+ tag = digitalRead(6);
+ suche_muster();
+ delay(15000);
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
- for(;;)
+ //for(;;)
;
+
}
}

0 comments on commit 9569a67

Please sign in to comment.