Hardware Reference
In-Depth Information
49 //Mains plug currently turned off
50 if (tempC < minTemp)
51 {
52 powerPinStatus = HIGH;
53 digitalWrite(powerPin, powerPinStatus);
54 }
55 }
56 else
57 {
58 // Mains plug currently turned on
59 if (tempC > maxTemp)
60 {
61 powerPinStatus = LOW;
62 digitalWrite(powerPin, powerPinStatus);
63 }
64 }
65
66 // Warn if possible heating element failure
67 if (tempC < (minTemp - 2))
68 {
69 Serial.print("CRITICAL: Water temperature too low. ");
70 Serial.println("Heating element failure?");
71 }
72
73 // Sleep for ten seconds
74 delay(10000);
75 }
76
77 // The loop responsible for lighting
78 void lightloop()
79 {
80 // Wait for 7 hours before turning the lights off
81 delay(7 * 60* 60 * 1000);
82
83 // Lower the light level over the span of one hour
84 for (i = 255; i >= 0; i--)
85 {
86 analogWrite(rPin, i); // Write the red light level
87 analogWrite(gPin, i); // Write the green light level
88 analogWrite(bPin, i); // Write the blue light level
89 delay(60 * 60 * 1000 / 255); //Sleep for a few seconds
90 }
91
92 // Wait for 11 hours
93 delay(11 * 60* 60 * 1000);
94
95 // Increase the light level over the span of one hour
96 for (i = 0; i <= 255; i++)
97 {
98 analogWrite(rPin, i); // Write the red light level
99 analogWrite(gPin, i); // Write the green light level
100 analogWrite(bPin, i); // Write the blue light level
Search WWH ::




Custom Search