-
Notifications
You must be signed in to change notification settings - Fork 0
/
HumidityFanControl.c
50 lines (44 loc) · 934 Bytes
/
HumidityFanControl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <avr/io.h>
#include <util/delay.h>
#define DATAPIN 9
#define FANSTARTLEVEL 68
#define FANSTOPLEVEL 66
#ifndef F_CPU
#warning "F_CPU war noch nicht definiert, wird nun mit 3686400 definiert"
#define F_CPU 3686400UL /* Quarz mit 3.6864 Mhz */
#endif
short GetCurrentHumidityLevel()
{
//assert(!"The method or operation is not implemented.");
return 59;
}
int SwitchFanState( int fanRunning )
{
if(fanRunning == 0 )
{
fanRunning = 1;
}
else
{
fanRunning = 0;
}
return fanRunning;
//assert(!"The method or operation is not implemented.");
}
int main(void)
{
int fanRunning = 0;
while(1)
{
short currentHumidityLevel = GetCurrentHumidityLevel();
if(fanRunning && currentHumidityLevel <= FANSTOPLEVEL)
{
fanRunning = SwitchFanState(fanRunning);
}
else if(!fanRunning && currentHumidityLevel >= FANSTARTLEVEL)
{
fanRunning = SwitchFanState(fanRunning);
}
_delay_ms(5000);
}
}