![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Eindprogramma met alle functies
Dependencies: DS1307 EthernetInterface TextLCD WebSocketClient mbed-rtos mbed
Fork of Hoofdprogramma by
Hoofdprogramma.cpp@7:0e4e558f57fe, 2015-01-06 (annotated)
- Committer:
- Bjorn
- Date:
- Tue Jan 06 18:46:21 2015 +0000
- Revision:
- 7:0e4e558f57fe
- Parent:
- 6:c95e2d561599
Eindprogramma met alle functies
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
R0375604 | 3:b2001b7e5c24 | 1 | // Pieter Essers & Bjorn Vranken GROEP5 |
R0375604 | 3:b2001b7e5c24 | 2 | // Digitale Temp Meting en aansturingen via |
R0375604 | 3:b2001b7e5c24 | 3 | // RGB LED // SERVO // RELAIS |
R0375604 | 0:f99036b05ce9 | 4 | #include "mbed.h" |
R0375604 | 0:f99036b05ce9 | 5 | #include "TextLCD.h" |
R0375604 | 3:b2001b7e5c24 | 6 | #include "ds1307.h" |
Bjorn | 7:0e4e558f57fe | 7 | #include <time.h> |
Bjorn | 7:0e4e558f57fe | 8 | #include "EthernetInterface.h" |
Bjorn | 7:0e4e558f57fe | 9 | #include "Websocket.h" |
R0375604 | 0:f99036b05ce9 | 10 | |
R0375604 | 0:f99036b05ce9 | 11 | // Declaratie van de Pinnen & variabelen |
R0375604 | 0:f99036b05ce9 | 12 | AnalogIn Temp1(p20); |
R0375604 | 0:f99036b05ce9 | 13 | AnalogIn Temp2(p19); |
R0375604 | 0:f99036b05ce9 | 14 | AnalogIn Temp3(p18); |
R0375604 | 0:f99036b05ce9 | 15 | |
R0375604 | 4:15258c48d16f | 16 | DigitalIn Druk1(p15); // temp1 |
R0375604 | 4:15258c48d16f | 17 | DigitalIn Druk2(p11); // temp2 |
R0375604 | 4:15258c48d16f | 18 | DigitalIn Druk3(p14); // temp3 |
R0375604 | 4:15258c48d16f | 19 | DigitalIn Down(p13); // up |
R0375604 | 4:15258c48d16f | 20 | DigitalIn Up(p12); // down |
R0375604 | 0:f99036b05ce9 | 21 | |
R0375604 | 1:386b4ee674e3 | 22 | DigitalOut Relais(p29); // pin voor de Relais |
R0375604 | 0:f99036b05ce9 | 23 | |
R0375604 | 0:f99036b05ce9 | 24 | PwmOut Servo(p21); // servo motor |
R0375604 | 4:15258c48d16f | 25 | PwmOut R(p23); // RGB => Rood |
R0375604 | 4:15258c48d16f | 26 | PwmOut G(p24); // RGB => Groen |
R0375604 | 4:15258c48d16f | 27 | PwmOut B(p22); // RGB => Blauw |
R0375604 | 0:f99036b05ce9 | 28 | PwmOut LedB(p25); // Blauwe Led als relais Uit is (Te warm) |
R0375604 | 0:f99036b05ce9 | 29 | PwmOut LedG(p26); // Groene Led als relais Uit is (Temp GOED) |
R0375604 | 0:f99036b05ce9 | 30 | |
R0375604 | 3:b2001b7e5c24 | 31 | TextLCD lcd(p5, p6, p7, p8, p9, p10); // LCD |
R0375604 | 3:b2001b7e5c24 | 32 | DS1307 my1307(p28,p27); // start DS1307 class and give it pins for connections of the DS1307 device |
R0375604 | 0:f99036b05ce9 | 33 | |
R0375604 | 3:b2001b7e5c24 | 34 | int sec; |
R0375604 | 3:b2001b7e5c24 | 35 | int min; |
R0375604 | 3:b2001b7e5c24 | 36 | int hours; |
R0375604 | 3:b2001b7e5c24 | 37 | int day; |
R0375604 | 3:b2001b7e5c24 | 38 | int date; |
R0375604 | 3:b2001b7e5c24 | 39 | int month; |
R0375604 | 3:b2001b7e5c24 | 40 | int year; |
R0375604 | 3:b2001b7e5c24 | 41 | |
R0375604 | 3:b2001b7e5c24 | 42 | float InstelTemp1 = 21; // De Gewenste Temperatuur |
R0375604 | 3:b2001b7e5c24 | 43 | float InstelTemp2 = 21; |
R0375604 | 3:b2001b7e5c24 | 44 | float InstelTemp3 = 21; |
R0375604 | 0:f99036b05ce9 | 45 | |
R0375604 | 0:f99036b05ce9 | 46 | float temp1 = 0; |
R0375604 | 0:f99036b05ce9 | 47 | float temp2 = 0; |
R0375604 | 0:f99036b05ce9 | 48 | float temp3 = 0; |
R0375604 | 0:f99036b05ce9 | 49 | |
R0375604 | 3:b2001b7e5c24 | 50 | //int teller = 0; // om een wachtlus te maken. |
R0375604 | 3:b2001b7e5c24 | 51 | void test_rw(int test) // Test voor de RTC |
R0375604 | 3:b2001b7e5c24 | 52 | { |
R0375604 | 3:b2001b7e5c24 | 53 | } |
R0375604 | 0:f99036b05ce9 | 54 | int main() |
R0375604 | 0:f99036b05ce9 | 55 | { |
R0375604 | 3:b2001b7e5c24 | 56 | lcd.cls(); // LCD Clearen |
R0375604 | 3:b2001b7e5c24 | 57 | R.period_ms(20.0f); // 20 msecond period (50Hz) |
R0375604 | 3:b2001b7e5c24 | 58 | G.period_ms(20.0f); // 20 msecond period (50Hz) |
R0375604 | 0:f99036b05ce9 | 59 | B.period_ms(20.0f); // 20 msecond period |
R0375604 | 1:386b4ee674e3 | 60 | LedB.period_ms(20.0f); // 20 msecond period |
R0375604 | 0:f99036b05ce9 | 61 | LedG.period_ms(20.0f); // 20 msecond period |
R0375604 | 0:f99036b05ce9 | 62 | lcd.cls(); // LCD Clearen |
Bjorn | 7:0e4e558f57fe | 63 | //-----------------Ethernet initialiseren-------------------------------------- |
Bjorn | 7:0e4e558f57fe | 64 | char json_str[1000]; //Maak een buffer aan voor de te verzenden karakters |
Bjorn | 7:0e4e558f57fe | 65 | |
Bjorn | 7:0e4e558f57fe | 66 | EthernetInterface eth; //Declareer de ethernet interface |
Bjorn | 7:0e4e558f57fe | 67 | eth.init(); //Use DHCP ip |
Bjorn | 7:0e4e558f57fe | 68 | eth.connect(); //Maak conectie met het gekregen ip adress |
R0375604 | 0:f99036b05ce9 | 69 | |
Bjorn | 7:0e4e558f57fe | 70 | |
Bjorn | 7:0e4e558f57fe | 71 | Websocket ws("ws://sockets.mbed.org:443/ws/DigiTempMeting/wo"); //server mbed |
Bjorn | 7:0e4e558f57fe | 72 | ws.connect(); //connectie maken met de server |
Bjorn | 7:0e4e558f57fe | 73 | wait(2.0); |
Bjorn | 7:0e4e558f57fe | 74 | //------------------------------------------------------------------------------- |
R0375604 | 0:f99036b05ce9 | 75 | while(1) |
R0375604 | 0:f99036b05ce9 | 76 | { |
R0375604 | 3:b2001b7e5c24 | 77 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
R0375604 | 3:b2001b7e5c24 | 78 | |
R0375604 | 0:f99036b05ce9 | 79 | float temp1 = 0; |
R0375604 | 0:f99036b05ce9 | 80 | float temp2 = 0; |
R0375604 | 0:f99036b05ce9 | 81 | float temp3 = 0; |
R0375604 | 3:b2001b7e5c24 | 82 | //------------- De Tijd op de LCD printen ------------------------------------ |
R0375604 | 3:b2001b7e5c24 | 83 | //------------- Enkel laten zien wanneer je op drukknop drukt----------------- |
R0375604 | 3:b2001b7e5c24 | 84 | while(Up) |
R0375604 | 3:b2001b7e5c24 | 85 | { |
R0375604 | 3:b2001b7e5c24 | 86 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
R0375604 | 3:b2001b7e5c24 | 87 | wait(0.5); |
R0375604 | 3:b2001b7e5c24 | 88 | lcd.cls(); |
R0375604 | 3:b2001b7e5c24 | 89 | lcd.locate(0,0); |
R0375604 | 3:b2001b7e5c24 | 90 | lcd.printf("%d:%d:%d",hours,min,sec); |
R0375604 | 3:b2001b7e5c24 | 91 | lcd.locate(0,1); |
R0375604 | 3:b2001b7e5c24 | 92 | lcd.printf("%d/%d/%d",date,month,year); |
R0375604 | 3:b2001b7e5c24 | 93 | } |
R0375604 | 1:386b4ee674e3 | 94 | //------------- Gewenste TEMP instellen ------------------------------------ |
R0375604 | 0:f99036b05ce9 | 95 | while(Druk1) // Gewenste Temp1 Instellen |
R0375604 | 0:f99036b05ce9 | 96 | { |
R0375604 | 0:f99036b05ce9 | 97 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 98 | lcd.printf("Instel Temp1 = "); |
R0375604 | 0:f99036b05ce9 | 99 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 100 | lcd.printf("%4.1f C ",InstelTemp1); |
R0375604 | 0:f99036b05ce9 | 101 | if(Down) |
R0375604 | 0:f99036b05ce9 | 102 | { |
R0375604 | 0:f99036b05ce9 | 103 | InstelTemp1 += 0.5; |
R0375604 | 0:f99036b05ce9 | 104 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 105 | lcd.printf("Instel Temp1 = "); |
R0375604 | 0:f99036b05ce9 | 106 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 107 | lcd.printf("%4.1f C ",InstelTemp1); |
R0375604 | 0:f99036b05ce9 | 108 | wait(0.5); |
R0375604 | 0:f99036b05ce9 | 109 | } |
R0375604 | 0:f99036b05ce9 | 110 | else if(Up) |
R0375604 | 0:f99036b05ce9 | 111 | { |
R0375604 | 0:f99036b05ce9 | 112 | InstelTemp1 -= 0.5; |
R0375604 | 0:f99036b05ce9 | 113 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 114 | lcd.printf("Instel Temp1 = "); |
R0375604 | 0:f99036b05ce9 | 115 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 116 | lcd.printf("%4.1f C ",InstelTemp1); |
R0375604 | 0:f99036b05ce9 | 117 | wait(0.5); |
R0375604 | 0:f99036b05ce9 | 118 | } |
R0375604 | 0:f99036b05ce9 | 119 | } |
R0375604 | 0:f99036b05ce9 | 120 | lcd.cls(); // LCD Clearen |
R0375604 | 0:f99036b05ce9 | 121 | while(Druk2) // Gewenste Temp2 Instellen |
R0375604 | 0:f99036b05ce9 | 122 | { |
R0375604 | 0:f99036b05ce9 | 123 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 124 | lcd.printf("Instel Temp2 = "); |
R0375604 | 0:f99036b05ce9 | 125 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 126 | lcd.printf("%4.1f C ",InstelTemp2); |
R0375604 | 0:f99036b05ce9 | 127 | if(Down) |
R0375604 | 0:f99036b05ce9 | 128 | { |
R0375604 | 0:f99036b05ce9 | 129 | InstelTemp2 += 0.5; |
R0375604 | 0:f99036b05ce9 | 130 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 131 | lcd.printf("Instel Temp2 = "); |
R0375604 | 0:f99036b05ce9 | 132 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 133 | lcd.printf("%4.1f C ",InstelTemp2); |
R0375604 | 0:f99036b05ce9 | 134 | wait(0.5); |
R0375604 | 0:f99036b05ce9 | 135 | } |
R0375604 | 0:f99036b05ce9 | 136 | else if(Up) |
R0375604 | 0:f99036b05ce9 | 137 | { |
R0375604 | 0:f99036b05ce9 | 138 | InstelTemp2 -= 0.5; |
R0375604 | 0:f99036b05ce9 | 139 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 140 | lcd.printf("Instel Temp2 = "); |
R0375604 | 0:f99036b05ce9 | 141 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 142 | lcd.printf("%4.1f C ",InstelTemp2); |
R0375604 | 0:f99036b05ce9 | 143 | wait(0.5); |
R0375604 | 0:f99036b05ce9 | 144 | } |
R0375604 | 0:f99036b05ce9 | 145 | } |
R0375604 | 0:f99036b05ce9 | 146 | lcd.cls(); // LCD Clearen |
R0375604 | 0:f99036b05ce9 | 147 | while(Druk3) // Gewenste Temp3 Instellen |
R0375604 | 0:f99036b05ce9 | 148 | { |
R0375604 | 0:f99036b05ce9 | 149 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 150 | lcd.printf("Instel Temp3 = "); |
R0375604 | 0:f99036b05ce9 | 151 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 152 | lcd.printf("%4.1f C ",InstelTemp3); |
R0375604 | 0:f99036b05ce9 | 153 | if(Down) |
R0375604 | 0:f99036b05ce9 | 154 | { |
R0375604 | 0:f99036b05ce9 | 155 | InstelTemp3 += 0.5; |
R0375604 | 0:f99036b05ce9 | 156 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 157 | lcd.printf("Instel Temp3 = "); |
R0375604 | 0:f99036b05ce9 | 158 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 159 | lcd.printf("%4.1f C ",InstelTemp3); |
R0375604 | 0:f99036b05ce9 | 160 | wait(0.5); |
R0375604 | 0:f99036b05ce9 | 161 | } |
R0375604 | 0:f99036b05ce9 | 162 | else if(Up) |
R0375604 | 0:f99036b05ce9 | 163 | { |
R0375604 | 0:f99036b05ce9 | 164 | InstelTemp3 -= 0.5; |
R0375604 | 0:f99036b05ce9 | 165 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 166 | lcd.printf("Instel Temp3 = "); |
R0375604 | 0:f99036b05ce9 | 167 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 168 | lcd.printf("%4.1f C ",InstelTemp3); |
R0375604 | 0:f99036b05ce9 | 169 | wait(0.5); |
R0375604 | 0:f99036b05ce9 | 170 | } |
R0375604 | 0:f99036b05ce9 | 171 | } |
R0375604 | 3:b2001b7e5c24 | 172 | //------------------------------------------------------------------------------------ |
R0375604 | 0:f99036b05ce9 | 173 | for(int t=0; t<100; t++) // Inlezen van de Temperatuur |
R0375604 | 0:f99036b05ce9 | 174 | { |
R0375604 | 0:f99036b05ce9 | 175 | temp1 = temp1 +Temp1.read(); // Temp1 inlezen |
R0375604 | 0:f99036b05ce9 | 176 | temp2 = temp2 +Temp2.read(); // Temp2 inlezen |
R0375604 | 0:f99036b05ce9 | 177 | temp3 = temp3 +Temp3.read(); // Temp3 inlezen |
R0375604 | 0:f99036b05ce9 | 178 | } |
R0375604 | 0:f99036b05ce9 | 179 | |
R0375604 | 5:1c493bae26fc | 180 | temp1 = (temp1 *3.3) + 3; // Bewerking voor de Temp in graden te bekomen. |
R0375604 | 5:1c493bae26fc | 181 | temp2 = (temp2 *3.3) + 3; |
R0375604 | 5:1c493bae26fc | 182 | temp3 = (temp3 *3.3) + 3; |
R0375604 | 1:386b4ee674e3 | 183 | //-------------- LCD Printen---------------------------------------------------------- |
R0375604 | 0:f99036b05ce9 | 184 | lcd.locate(0,0); // De ingelezen Temperatuur op de LCD zetten |
R0375604 | 0:f99036b05ce9 | 185 | lcd.printf("Temperatuur 1 = "); |
R0375604 | 0:f99036b05ce9 | 186 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 187 | lcd.printf("%4.1f C ",temp1); |
R0375604 | 1:386b4ee674e3 | 188 | wait(1.5); |
R0375604 | 0:f99036b05ce9 | 189 | lcd.cls(); |
R0375604 | 0:f99036b05ce9 | 190 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 191 | lcd.printf("Temperatuur 2 = "); |
R0375604 | 0:f99036b05ce9 | 192 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 193 | lcd.printf("%4.1f C ",temp2); |
R0375604 | 1:386b4ee674e3 | 194 | wait(1.5); |
R0375604 | 0:f99036b05ce9 | 195 | lcd.cls(); |
R0375604 | 0:f99036b05ce9 | 196 | lcd.locate(0,0); |
R0375604 | 0:f99036b05ce9 | 197 | lcd.printf("Temperatuur 3 = "); |
R0375604 | 0:f99036b05ce9 | 198 | lcd.locate(0,1); |
R0375604 | 0:f99036b05ce9 | 199 | lcd.printf("%4.1f C ",temp3); |
R0375604 | 1:386b4ee674e3 | 200 | wait(1.5); |
R0375604 | 3:b2001b7e5c24 | 201 | //-----------// RGB => Temperatuur 1// WAARSCHUWIGS SIGNAAL-------------------------------------------------------- |
R0375604 | 5:1c493bae26fc | 202 | //------Naarmate temp verder van gewenste waarde zit een andre RGB kleur-------------- |
R0375604 | 5:1c493bae26fc | 203 | //------------------------Te warme Temp----------------------------------------------- |
R0375604 | 5:1c493bae26fc | 204 | if(InstelTemp1 + 1 < temp1 && temp1 <= InstelTemp1 + 2) |
R0375604 | 0:f99036b05ce9 | 205 | { |
R0375604 | 5:1c493bae26fc | 206 | R.write(0.50f); // 50% duty cycle Geel |
R0375604 | 5:1c493bae26fc | 207 | G.write(0.50f); // 50% duty cycle |
R0375604 | 0:f99036b05ce9 | 208 | B.write(0.00f); // 0% duty cycle |
R0375604 | 5:1c493bae26fc | 209 | } |
R0375604 | 5:1c493bae26fc | 210 | else if(InstelTemp1 + 2 < temp1 && temp1 <= InstelTemp1 + 3) |
R0375604 | 5:1c493bae26fc | 211 | { |
R0375604 | 5:1c493bae26fc | 212 | R.write(0.75f); // 50% duty cycle Oranje |
R0375604 | 5:1c493bae26fc | 213 | G.write(0.25f); // 25% duty cycle |
R0375604 | 5:1c493bae26fc | 214 | B.write(0.00f); // 0% duty cycle |
R0375604 | 5:1c493bae26fc | 215 | } |
R0375604 | 5:1c493bae26fc | 216 | else if(InstelTemp1 + 3 < temp1) |
R0375604 | 5:1c493bae26fc | 217 | { |
R0375604 | 5:1c493bae26fc | 218 | R.write(0.50f); // 50% duty cycle Rood |
R0375604 | 5:1c493bae26fc | 219 | G.write(0.00f); // 0% duty cycle |
R0375604 | 5:1c493bae26fc | 220 | B.write(0.00f); // 0% duty cycle |
R0375604 | 5:1c493bae26fc | 221 | } |
R0375604 | 5:1c493bae26fc | 222 | //---------------Te koude temp---------------------------------------------- |
R0375604 | 5:1c493bae26fc | 223 | else if(InstelTemp1 - 1 > temp1 && temp1 >= InstelTemp1 - 2) |
R0375604 | 3:b2001b7e5c24 | 224 | { |
R0375604 | 5:1c493bae26fc | 225 | R.write(0.00f); // 0% duty cycle Licht blauw |
R0375604 | 5:1c493bae26fc | 226 | G.write(0.50f); // 50% duty cycle |
R0375604 | 5:1c493bae26fc | 227 | B.write(0.50f); // 50% duty cycle |
R0375604 | 5:1c493bae26fc | 228 | } |
R0375604 | 5:1c493bae26fc | 229 | else if(InstelTemp1 - 2 > temp1 && temp1 >= InstelTemp1 - 3) |
R0375604 | 5:1c493bae26fc | 230 | { |
R0375604 | 5:1c493bae26fc | 231 | R.write(0.00f); // 0% duty cycle Paars |
R0375604 | 5:1c493bae26fc | 232 | G.write(0.25f); // 25% duty cycle |
R0375604 | 5:1c493bae26fc | 233 | B.write(0.75f); // 75% duty cycle |
R0375604 | 5:1c493bae26fc | 234 | } |
R0375604 | 6:c95e2d561599 | 235 | else if(InstelTemp1 - 3 > temp1) |
R0375604 | 5:1c493bae26fc | 236 | { |
R0375604 | 6:c95e2d561599 | 237 | R.write(0.00f); // 0% duty cycle Blauw |
R0375604 | 3:b2001b7e5c24 | 238 | G.write(0.00f); // 0% duty cycle |
R0375604 | 5:1c493bae26fc | 239 | B.write(0.50f); // 50% duty cycle |
R0375604 | 5:1c493bae26fc | 240 | } |
R0375604 | 5:1c493bae26fc | 241 | //-------------Goede Temp------------------------------------------------- |
R0375604 | 0:f99036b05ce9 | 242 | else // Temp is te GOED => Groene led |
R0375604 | 0:f99036b05ce9 | 243 | { |
R0375604 | 0:f99036b05ce9 | 244 | R.write(0.00f); // 0% duty cycle |
R0375604 | 0:f99036b05ce9 | 245 | G.write(0.50f); // 50% duty cycle |
R0375604 | 0:f99036b05ce9 | 246 | B.write(0.00f); // 0% duty cycle |
R0375604 | 1:386b4ee674e3 | 247 | } |
R0375604 | 2:52f7cccebdea | 248 | //-----------// Relais => Temperatuur 2// Moet met een transistor---------------------------------- |
R0375604 | 1:386b4ee674e3 | 249 | if(temp2 > InstelTemp2 + 2) // Temp is te HOOG => Blauwe led |
R0375604 | 1:386b4ee674e3 | 250 | { |
R0375604 | 1:386b4ee674e3 | 251 | Relais = 0; // Temp is te HOOG dus moet afkoelen (Niet verwarmen) |
R0375604 | 1:386b4ee674e3 | 252 | LedB.write(0.50f); // 50% duty cycle |
R0375604 | 1:386b4ee674e3 | 253 | LedG.write(0.00f); // 0% duty cycle |
R0375604 | 1:386b4ee674e3 | 254 | |
R0375604 | 1:386b4ee674e3 | 255 | } |
R0375604 | 2:52f7cccebdea | 256 | else if (temp2 < InstelTemp2 - 2) // Temp is te LAAG => Rode led |
R0375604 | 1:386b4ee674e3 | 257 | { |
R0375604 | 1:386b4ee674e3 | 258 | Relais = 1; // Temp is te LAAG Dus verwarmen |
R0375604 | 3:b2001b7e5c24 | 259 | wait(0.5); |
R0375604 | 2:52f7cccebdea | 260 | LedB.write(0.00f); // 0% duty cycle |
R0375604 | 2:52f7cccebdea | 261 | LedG.write(0.00f); // 0% duty cycle |
R0375604 | 1:386b4ee674e3 | 262 | } |
R0375604 | 1:386b4ee674e3 | 263 | else // Temp is te GOED => Groene led |
R0375604 | 1:386b4ee674e3 | 264 | { |
R0375604 | 3:b2001b7e5c24 | 265 | Relais = 0; // Tem is GOED dus niets doen |
R0375604 | 1:386b4ee674e3 | 266 | LedB.write(0.00f); // 0% duty cycle |
R0375604 | 3:b2001b7e5c24 | 267 | LedG.write(0.50f); // 100% duty cycle |
R0375604 | 1:386b4ee674e3 | 268 | } |
R0375604 | 1:386b4ee674e3 | 269 | //-----------// Servo => Temparatur 3 // ------------------------------------------------------------ |
R0375604 | 5:1c493bae26fc | 270 | //---------------------Stappen naar rechts -> Te WARM----------------------------------------------- |
R0375604 | 5:1c493bae26fc | 271 | if(InstelTemp3 + 1 < temp3 && temp3 <= InstelTemp3 + 2) |
R0375604 | 5:1c493bae26fc | 272 | { |
R0375604 | 6:c95e2d561599 | 273 | Servo = (110 * 0.000511 + 0.026); // rechts |
R0375604 | 5:1c493bae26fc | 274 | } |
R0375604 | 5:1c493bae26fc | 275 | else if(InstelTemp3 + 2 < temp3 && temp3 <= InstelTemp3 + 3) |
R0375604 | 5:1c493bae26fc | 276 | { |
R0375604 | 6:c95e2d561599 | 277 | Servo = (130 * 0.000511 + 0.026); // rechts |
R0375604 | 5:1c493bae26fc | 278 | } |
R0375604 | 5:1c493bae26fc | 279 | else if(InstelTemp3 + 3 < temp3 && temp3 <= InstelTemp3 + 4) |
R0375604 | 5:1c493bae26fc | 280 | { |
R0375604 | 6:c95e2d561599 | 281 | Servo = (150 * 0.000511 + 0.026); // rechts |
R0375604 | 5:1c493bae26fc | 282 | } |
R0375604 | 5:1c493bae26fc | 283 | else if(InstelTemp3 + 4 < temp3) |
R0375604 | 1:386b4ee674e3 | 284 | { |
R0375604 | 1:386b4ee674e3 | 285 | Servo = (170 * 0.000511 + 0.026); // rechts |
R0375604 | 1:386b4ee674e3 | 286 | } |
R0375604 | 5:1c493bae26fc | 287 | //---------------------Stappen naar links -> Te KOUD----------------------------------------------- |
R0375604 | 5:1c493bae26fc | 288 | else if(InstelTemp3 - 1 > temp3 && temp3 >= InstelTemp3 - 2) |
R0375604 | 5:1c493bae26fc | 289 | { |
R0375604 | 6:c95e2d561599 | 290 | Servo = (70 * 0.000511 + 0.026); // links |
R0375604 | 5:1c493bae26fc | 291 | } |
R0375604 | 5:1c493bae26fc | 292 | else if(InstelTemp3 - 2 > temp3 && temp3 >= InstelTemp3 - 3) |
R0375604 | 1:386b4ee674e3 | 293 | { |
R0375604 | 6:c95e2d561599 | 294 | Servo = (50 * 0.000511 + 0.026); // links |
R0375604 | 5:1c493bae26fc | 295 | } |
R0375604 | 5:1c493bae26fc | 296 | else if(InstelTemp3 - 3 > temp3 && temp3 >= InstelTemp3 - 4) |
R0375604 | 5:1c493bae26fc | 297 | { |
R0375604 | 6:c95e2d561599 | 298 | Servo = (30 * 0.000511 + 0.026); // links |
R0375604 | 1:386b4ee674e3 | 299 | } |
R0375604 | 5:1c493bae26fc | 300 | else if(InstelTemp3 - 4 > temp3) |
R0375604 | 5:1c493bae26fc | 301 | { |
R0375604 | 5:1c493bae26fc | 302 | Servo = (7 * 0.000511 + 0.026); // links |
R0375604 | 5:1c493bae26fc | 303 | } |
R0375604 | 5:1c493bae26fc | 304 | //--------------Temp is goed------------------------------------------------------------ |
R0375604 | 1:386b4ee674e3 | 305 | else // Temp is te GOED => Servo Midden |
R0375604 | 1:386b4ee674e3 | 306 | { |
R0375604 | 1:386b4ee674e3 | 307 | Servo = (90 * 0.000511 + 0.026); // rust |
R0375604 | 1:386b4ee674e3 | 308 | } |
Bjorn | 7:0e4e558f57fe | 309 | //------------------------Ethernet weg schrijven--------------------------------------------- |
Bjorn | 7:0e4e558f57fe | 310 | sprintf(json_str,"-----------------------------------------------------------------------------------------"); |
Bjorn | 7:0e4e558f57fe | 311 | ws.send(json_str); |
Bjorn | 7:0e4e558f57fe | 312 | sprintf(json_str,"Temperatuur 3 is: %4.1f C met een ingestelde temperatuur van %4.1f C " ,temp3,InstelTemp3); |
Bjorn | 7:0e4e558f57fe | 313 | ws.send(json_str); |
Bjorn | 7:0e4e558f57fe | 314 | sprintf(json_str,"Temperatuur 2 is: %4.1f C met een ingestelde temperatuur van %4.1f C " ,temp2,InstelTemp2); |
Bjorn | 7:0e4e558f57fe | 315 | ws.send(json_str); |
Bjorn | 7:0e4e558f57fe | 316 | sprintf(json_str,"Temperatuur 1 is: %4.1f C met een ingestelde temperatuur van %4.1f C " ,temp1,InstelTemp1); |
Bjorn | 7:0e4e558f57fe | 317 | ws.send(json_str); |
Bjorn | 7:0e4e558f57fe | 318 | sprintf(json_str,"De datum op het moment van de meting is: %d:%d:%d",date,month,year); |
Bjorn | 7:0e4e558f57fe | 319 | ws.send(json_str); |
Bjorn | 7:0e4e558f57fe | 320 | sprintf(json_str,"De tijd op het moment van de meting is: %d:%d:%d",hours,min,sec); |
Bjorn | 7:0e4e558f57fe | 321 | ws.send(json_str); |
Bjorn | 7:0e4e558f57fe | 322 | wait(2.0); |
R0375604 | 2:52f7cccebdea | 323 | //-------------------------------------------------------------------------------------------------- |
R0375604 | 0:f99036b05ce9 | 324 | } |
R0375604 | 5:1c493bae26fc | 325 | } |