Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added option today or tomorrow

  • Loading branch information...
commit 9569a674e1db5e61a3769916fd83dafcd88fcda3 1 parent 526b674
Torsten authored October 30, 2011

Showing 1 changed file with 105 additions and 79 deletions. Show diff stats Hide diff stats

  1. 184  wetterhaus.ino
184  wetterhaus.ino
@@ -21,6 +21,7 @@ char muster[4][6] ={
21 21
 char temp_zahl[3];
22 22
 int regenwahrscheinlickeit = 0;
23 23
 
  24
+int tag        = 1; // 0 = heute 1 = morgen
24 25
 int nr_zeichen = 0;
25 26
 int nr_muster  = 0;
26 27
 int ausgabe    = 0;
@@ -41,71 +42,105 @@ Servo myservo;
41 42
 void suche_muster()
42 43
 {
43 44
   //Hilffunktion zum füllen der Variable für die Regenwahrscheinlichkeit
44  
-    char c = client.read();
45  
-    if( c == muster[nr_muster][nr_zeichen]) // Muster zeichenweise vergleichen
46  
-    {
47  
-      if (nr_zeichen < 5 ) 
48  
-        {nr_zeichen++;}
49  
-      else // Muster gefunden
50  
-        {
51  
-          if (debug_on) {Serial.print("Muster gefunden ");Serial.print(nr_muster);}
52  
-          ausgabe++;
53  
-          nr_zeichen =0;
54  
-          nr_muster++;
55  
-                  
56  
-        }
57  
-    
58  
-    }
59  
-    else
  45
+   
  46
+ if (client.connect(server, 80)) {
  47
+    Serial.println("connected ");
  48
+    Serial.println(tag);
  49
+    // Make a HTTP request:
  50
+    switch(tag)
60 51
     {
61  
-      nr_zeichen=0;
  52
+      case 0:
  53
+        client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-aktuell.html");
  54
+      break;
  55
+      case 1:
  56
+        client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-morgen.html");
  57
+      break;
  58
+      default:
  59
+        client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-morgen.html");
  60
+      break;
62 61
     }
63  
-    if (ausgabe == 2) 
  62
+    
  63
+    client.println();
  64
+  } 
  65
+  else {
  66
+    // kf you didn't get a connection to the server:
  67
+    Serial.println("connection failed");
  68
+  }   
  69
+    while(client.available() && ausgabe < 7)
64 70
     {
65  
-      if (debug_on) Serial.print(c);
66  
-      switch (c) {
67  
-        case '1':
68  
-          temp_zahl[zaehler] = c;
69  
-          zaehler++;
70  
-        break;
71  
-        case '2':
72  
-          temp_zahl[zaehler] = c;
73  
-          zaehler++;
74  
-        break;
75  
-        case '3':
76  
-          temp_zahl[zaehler] = c;
77  
-          zaehler++;
78  
-        break;
79  
-        case '4':
80  
-          temp_zahl[zaehler] = c;
81  
-          zaehler++;
82  
-        break;
83  
-        case '5':
84  
-          temp_zahl[zaehler] = c;
85  
-          zaehler++;
86  
-        break;
87  
-        case '6':
88  
-          temp_zahl[zaehler] = c;
89  
-          zaehler++;
90  
-        break;
91  
-        case '7':
92  
-          temp_zahl[zaehler] = c;
93  
-          zaehler++;
94  
-        break;
95  
-        case '8':
96  
-          temp_zahl[zaehler] = c;
97  
-          zaehler++;
98  
-        break;
99  
-        case '9':
100  
-          temp_zahl[zaehler] = c;
101  
-          zaehler++;
102  
-        break;
103  
-        case '0':
104  
-          temp_zahl[zaehler] = c;
105  
-          zaehler++;
106  
-        break;
  71
+      char c = client.read();
  72
+      if( c == muster[nr_muster][nr_zeichen]) // Muster zeichenweise vergleichen
  73
+      {
  74
+        if (nr_zeichen < 5 ) 
  75
+          {nr_zeichen++;}
  76
+        else // Muster gefunden
  77
+          {
  78
+            if (debug_on) {Serial.print("Muster gefunden ");Serial.print(nr_muster);}
  79
+            ausgabe++;
  80
+            nr_zeichen =0;
  81
+            nr_muster++;
  82
+                    
  83
+          }
  84
+      
  85
+      }
  86
+      else
  87
+      {
  88
+        nr_zeichen=0;
107 89
       }
  90
+      if (ausgabe == 2) 
  91
+      {
  92
+        if (debug_on) Serial.print(c);
  93
+        switch (c) {
  94
+          case '1':
  95
+            temp_zahl[zaehler] = c;
  96
+            zaehler++;
  97
+          break;
  98
+          case '2':
  99
+            temp_zahl[zaehler] = c;
  100
+            zaehler++;
  101
+          break;
  102
+          case '3':
  103
+            temp_zahl[zaehler] = c;
  104
+            zaehler++;
  105
+          break;
  106
+          case '4':
  107
+            temp_zahl[zaehler] = c;
  108
+            zaehler++;
  109
+          break;
  110
+          case '5':
  111
+            temp_zahl[zaehler] = c;
  112
+            zaehler++;
  113
+          break;
  114
+          case '6':
  115
+            temp_zahl[zaehler] = c;
  116
+            zaehler++;
  117
+          break;
  118
+          case '7':
  119
+            temp_zahl[zaehler] = c;
  120
+            zaehler++;
  121
+          break;
  122
+          case '8':
  123
+            temp_zahl[zaehler] = c;
  124
+            zaehler++;
  125
+          break;
  126
+          case '9':
  127
+            temp_zahl[zaehler] = c;
  128
+            zaehler++;
  129
+          break;
  130
+          case '0':
  131
+            temp_zahl[zaehler] = c;
  132
+            zaehler++;
  133
+          break;
  134
+        } // end Case
  135
+        
  136
+      } // 
  137
+    } // end  while loop
  138
+    if (ausgabe==3)
  139
+    {
108 140
       
  141
+      ausgabe = 9;
  142
+      int regen = atoi(temp_zahl);
  143
+      myservo.write(map(regen,0,100,150,30));
109 144
     }
110 145
   }
111 146
 
@@ -114,7 +149,11 @@ void suche_muster()
114 149
 void setup() {
115 150
   // start the serial library:
116 151
   Serial.begin(57600);
  152
+  pinMode(5, OUTPUT);
  153
+  pinMode(6, INPUT);
  154
+  digitalWrite(5, HIGH);
117 155
   myservo.attach(9);
  156
+  myservo.write(90);
118 157
   // start the Ethernet connection:
119 158
   if (Ethernet.begin(mac) == 0) {
120 159
     Serial.println("Failed to configure Ethernet using DHCP");
@@ -127,16 +166,7 @@ void setup() {
127 166
   Serial.println("connecting...");
128 167
 
129 168
   // if you get a connection, report back via serial:
130  
-  if (client.connect(server, 80)) {
131  
-    Serial.println("connected");
132  
-    // Make a HTTP request:
133  
-    client.println("GET /wettervorhersage/49-2661-39/wetter-sankt-augustin/wetterbericht-morgen.html");
134  
-    client.println();
135  
-  } 
136  
-  else {
137  
-    // kf you didn't get a connection to the server:
138  
-    Serial.println("connection failed");
139  
-  }
  169
+
140 170
 }
141 171
 
142 172
 // ------------------ Hauptprogramm ---------------------------------------
@@ -145,14 +175,9 @@ void loop()
145 175
 {
146 176
   // if there are incoming bytes available 
147 177
   // from the server, read them and print them:
148  
-  if (client.available() && ausgabe < 7) { suche_muster(); }
149  
-  if (ausgabe==3)
150  
-  {
151  
-    
152  
-    ausgabe = 9;
153  
-    int regen = atoi(temp_zahl);
154  
-    myservo.write(map(regen,0,100,150,30));
155  
-  }
  178
+  tag = digitalRead(6);
  179
+  suche_muster(); 
  180
+  delay(15000);
156 181
   // if the server's disconnected, stop the client:
157 182
   if (!client.connected()) {
158 183
     Serial.println();
@@ -160,8 +185,9 @@ void loop()
160 185
     client.stop();
161 186
 
162 187
     // do nothing forevermore:
163  
-    for(;;)
  188
+    //for(;;)
164 189
       ;
  190
+   
165 191
   }
166 192
 }
167 193
 

0 notes on commit 9569a67

Please sign in to comment.
Something went wrong with that request. Please try again.