Eindprogramma met alle functies
Dependencies: DS1307 EthernetInterface TextLCD WebSocketClient mbed-rtos mbed
Fork of Hoofdprogramma by
Diff: Hoofdprogramma.cpp
- Revision:
- 3:b2001b7e5c24
- Parent:
- 2:52f7cccebdea
- Child:
- 4:15258c48d16f
diff -r 52f7cccebdea -r b2001b7e5c24 Hoofdprogramma.cpp --- a/Hoofdprogramma.cpp Fri Nov 28 13:14:12 2014 +0000 +++ b/Hoofdprogramma.cpp Thu Dec 04 10:06:59 2014 +0000 @@ -1,5 +1,9 @@ +// Pieter Essers & Bjorn Vranken GROEP5 +// Digitale Temp Meting en aansturingen via +// RGB LED // SERVO // RELAIS #include "mbed.h" #include "TextLCD.h" +#include "ds1307.h" // Declaratie van de Pinnen & variabelen AnalogIn Temp1(p20); @@ -21,31 +25,58 @@ PwmOut LedB(p25); // Blauwe Led als relais Uit is (Te warm) PwmOut LedG(p26); // Groene Led als relais Uit is (Temp GOED) -TextLCD lcd(p5, p6, p7, p8, p9, p10); +TextLCD lcd(p5, p6, p7, p8, p9, p10); // LCD +DS1307 my1307(p28,p27); // start DS1307 class and give it pins for connections of the DS1307 device -float InstelTemp1 = 22; // De Gewenste Temperatuur -float InstelTemp2 = 30; -float InstelTemp3 = 22; +int sec; +int min; +int hours; +int day; +int date; +int month; +int year; + +float InstelTemp1 = 21; // De Gewenste Temperatuur +float InstelTemp2 = 21; +float InstelTemp3 = 21; float temp1 = 0; float temp2 = 0; float temp3 = 0; +//int teller = 0; // om een wachtlus te maken. +void test_rw(int test) // Test voor de RTC +{ +} int main() { - R.period_ms(20.0f); // 20 msecond period - G.period_ms(20.0f); // 20 msecond period + lcd.cls(); // LCD Clearen + R.period_ms(20.0f); // 20 msecond period (50Hz) + G.period_ms(20.0f); // 20 msecond period (50Hz) B.period_ms(20.0f); // 20 msecond period LedB.period_ms(20.0f); // 20 msecond period LedG.period_ms(20.0f); // 20 msecond period - lcd.cls(); // LCD Clearen while(1) { + my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); + float temp1 = 0; float temp2 = 0; float temp3 = 0; + //------------- De Tijd op de LCD printen ------------------------------------ + //------------- Enkel laten zien wanneer je op drukknop drukt----------------- + while(Up) + { + my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); + wait(0.5); + lcd.cls(); + lcd.locate(0,0); + lcd.printf("%d:%d:%d",hours,min,sec); + lcd.locate(0,1); + lcd.printf("%d/%d/%d",date,month,year); + } //------------- Gewenste TEMP instellen ------------------------------------ while(Druk1) // Gewenste Temp1 Instellen { @@ -124,8 +155,7 @@ wait(0.5); } } - //------------------------------------------------------------------------------------ - lcd.cls(); // LCD Clearen + //------------------------------------------------------------------------------------ for(int t=0; t<100; t++) // Inlezen van de Temperatuur { temp1 = temp1 +Temp1.read(); // Temp1 inlezen @@ -154,18 +184,18 @@ lcd.locate(0,1); lcd.printf("%4.1f C ",temp3); wait(1.5); -//-----------// RGB => Temperatuur 1// ------------------------------------------------------------ - if(temp1 > InstelTemp1 + 2) // Temp is te HOOG => Blauwe led +//-----------// RGB => Temperatuur 1// WAARSCHUWIGS SIGNAAL-------------------------------------------------------- + if(temp1 > InstelTemp1 + 2) // Temp is te HOOG => Rode led OPGEPAST TE WARM ------ InstelTemp1 + 1 < temp1 <= InstelTemp1 + 1,5 { - R.write(0.00f); // 0% duty cycle - G.write(0.00f); // 0% duty cycle - B.write(0.50f); // 50% duty cycle - } - else if (temp1 < InstelTemp1 - 2) // Temp is te LAAG => Rode led - { - R.write(0.50f); // 50% duty cycle + R.write(0.50f); // 50% duty cycle LED GAAT GW AAN G.write(0.00f); // 0% duty cycle B.write(0.00f); // 0% duty cycle + } + else if (temp1 < InstelTemp1 - 2) // Temp is te LAAG => Blauwe led LET OP TE KOUD + { + R.write(0.00f); // 50% duty cycle + G.write(0.00f); // 0% duty cycle + B.write(0.50f); // 0% duty cycle } else // Temp is te GOED => Groene led { @@ -184,30 +214,28 @@ else if (temp2 < InstelTemp2 - 2) // Temp is te LAAG => Rode led { Relais = 1; // Temp is te LAAG Dus verwarmen + wait(0.5); LedB.write(0.00f); // 0% duty cycle LedG.write(0.00f); // 0% duty cycle } else // Temp is te GOED => Groene led { - Relais = 0; // Tem is GOED dus niets doen + Relais = 0; // Tem is GOED dus niets doen LedB.write(0.00f); // 0% duty cycle - LedG.write(0.50f); // 50% duty cycle + LedG.write(0.50f); // 100% duty cycle } //-----------// Servo => Temparatur 3 // ------------------------------------------------------------ if(temp3 > InstelTemp3 + 2) // Temp is te HOOG => Servo Rechts { Servo = (170 * 0.000511 + 0.026); // rechts - wait(2); } else if (temp3 < InstelTemp3 - 2) // Temp is te LAAG => Servo Links { Servo = (7 * 0.000511 + 0.026); // links 7 - wait(2); } else // Temp is te GOED => Servo Midden { Servo = (90 * 0.000511 + 0.026); // rust - wait(2); } //-------------------------------------------------------------------------------------------------- }