Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Adafruit_GFX DS1820
Revision 2:6c5d798a1092, committed 2022-06-29
- Comitter:
- pavlem
- Date:
- Wed Jun 29 15:21:52 2022 +0000
- Parent:
- 1:aa2a0b18bdb1
- Commit message:
- Dodata regulacija;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jun 29 12:35:37 2022 +0000
+++ b/main.cpp Wed Jun 29 15:21:52 2022 +0000
@@ -12,7 +12,6 @@
#include "Adafruit_GFX.h"
#include "Adafruit_GFX_Config.h"
#include "Adafruit_SSD1306.h"
-#include "DHT.h"
#include "DS1820.h"
#include <ctype.h>
@@ -60,6 +59,7 @@
// Relay selection signals
DigitalOut relay_select1(PA_10); // D2
DigitalOut relay_select2(PB_3); // D3
+DigitalOut fan_on(PB_5); // D3
// DS1820 sensor object
DS1820* probe[MAX_PROBES];
@@ -102,6 +102,7 @@
{
char cmd = 0;
int ref_temp = 0;
+ char regulation_on = 0;
// Initialize OLED:
myOled.begin();
@@ -138,7 +139,7 @@
scanf("%d", &ref_temp);
if (ref_temp > TEMP_MIN && ref_temp < TEMP_MAX)
{
- temp_timer.attach(&ISR_temp, TEMP_DELAY);
+ temp_timer.attach(&ISR_temp, TEMP_DELAY);
}
cmd = 0;
}
@@ -146,8 +147,27 @@
if (data_acquired)
{
refresh_display();
+
+ if (abs(temp-ref_temp)>0.1)
+ {
+ fan_on = 1;
+ if (temp > ref_temp)
+ {
+ // Turn on the cooling
+ relay_select1 = 0;
+ relay_select2 = 1;
+ }
+ else
+ {
+ // Turn on the heating
+ relay_select1 = 1;
+ relay_select2 = 0;
+ }
+ }
+
data_acquired = 0;
}
+
}
}
@@ -187,9 +207,9 @@
// ISR for temperature acquisition
void ISR_temp (void)
{
- printf("t\n");
probe[0]->convertTemperature(true, DS1820::all_devices);
- printf("It is %3.1foC\r\n", probe[0]->temperature());
+ temp = probe[0]->temperature();
+ printf("It is %3.1foC\r\n", temp);
data_acquired = 1;
}