This repository was archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10_lights.ino
86 lines (78 loc) · 1.78 KB
/
10_lights.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
void lightFade(int8_t x) {
char illuminate[16];
uint8_t lastPercent;
while ((brightness > 0) && (brightness < 255))
{
brightness = brightness + x;
analogWrite(ledPin, brightness);
if ((x == 1) && (brightness == 140))
{
lcd.setBacklight(HIGH);
}
else if ((x == -1) && (brightness == 140))
{
lcd.setBacklight(LOW);
}
else {
break;
}
uint16_t percent = map(brightness, 0, maxPWMsteps, 0, 100);
if (percent != lastPercent)
{
sprintf(illuminate, "ILLUMINATING %d%", percent);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(illuminate);
}
lastPercent = percent;
delay(fadeDelay);
}
Serial.println("end of lightfade");
}
void lightFadeOn(uint16_t y = fadeDelay, uint8_t z = maxPWMsteps) {
char illuminate[16];
uint8_t lastPercent;
while ( brightness < z)
{
brightness++;
if (brightness > 140)
{
lcd.setBacklight(HIGH);
}
uint16_t percent = map(brightness, 0, z, 0, 100);
if (percent != lastPercent)
{
sprintf(illuminate, "ILLUMINATING %d%", percent);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(illuminate);
}
lastPercent = percent;
analogWrite(ledPin, brightness);
delay(y);
}
}
void lightFadeOff(uint16_t y = fadeDelay, uint8_t z = maxPWMsteps) {
char dim[8];
uint8_t lastPercent;
uint8_t brightness = z;
while ( brightness > 0)
{
brightness--;
if (brightness < 140)
{
lcd.setBacklight(LOW);
}
uint16_t percent = map(brightness, 0, z, 0, 100);
if (percent != lastPercent)
{
sprintf(dim, "DIMMING %d%", percent);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(dim);
}
lastPercent = percent;
analogWrite(ledPin, brightness);
delay(y);
}
}