-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlight.ino
executable file
·54 lines (48 loc) · 927 Bytes
/
light.ino
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
51
52
53
54
void light()
// Operating the SSR (turning the lights on/off) based on light_state
{
// SSR cannot be controlled if we went over the critical temperature:
if (bad_temp)
return;
if (light_state != light_state_old && phys_flip == 0)
{
if (light_state == 0)
// Turning off
{
#ifdef SERVO
Servo1.attach(SWITCH_PIN);
Servo1.write(SERVO_OFF);
delay(SERVO_DELAY_MS);
Servo1.detach();
#else
#ifdef INVERT
digitalWrite(SSR_PIN, HIGH);
#else
digitalWrite(SSR_PIN, LOW);
#endif
#endif
#ifdef DEBUG
Serial.println("SSR off");
#endif
}
else
// Turning on
{
#ifdef SERVO
Servo1.attach(SWITCH_PIN);
Servo1.write(SERVO_ON);
delay(SERVO_DELAY_MS);
Servo1.detach();
#else
#ifdef INVERT
digitalWrite(SSR_PIN, LOW);
#else
digitalWrite(SSR_PIN, HIGH);
#endif
#endif
#ifdef DEBUG
Serial.println("SSR on");
#endif
}
}
}