-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple manual replacement controller for the heating.
- Loading branch information
Adrian McEwen
committed
Jan 18, 2016
1 parent
580b716
commit 7528fff
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
Network/ManualHeatingController/ManualHeatingController.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Manual replacement for the YaHMS controller used on the | ||
// heating in DoES Liverpool | ||
// | ||
// Use it when the network is down and the existing controller | ||
// can't receive its instructions | ||
// | ||
// Circuit: | ||
// Needs a pushbutton connected to 5V on one side and kSwitchPin | ||
// on the other, with kSwitchPin also connected to ground through | ||
// a pull-down resistor | ||
// And an LED connected to pin kIndicatorPin will illuminate | ||
// whenever the heating is on | ||
// | ||
// Usage: | ||
// Heating is turned on when the LED is lit | ||
// Pressing the pushbutton will toggle the heating between | ||
// on and off | ||
|
||
const int kHeatingPin = 14; | ||
const int kSwitchPin = 2; | ||
const int kIndicatorPin = 13; | ||
const int kDebounceDelay = 500; | ||
|
||
int gLastButtonState = LOW; | ||
unsigned long gLastSwitchTime = 0UL; | ||
bool gHeatingState = false; | ||
|
||
void setup() { | ||
// put your setup code here, to run once: | ||
pinMode(kHeatingPin, OUTPUT); | ||
pinMode(kSwitchPin, INPUT); | ||
pinMode(kIndicatorPin, OUTPUT); | ||
|
||
digitalWrite(kIndicatorPin, HIGH); | ||
delay(300); | ||
digitalWrite(kIndicatorPin, LOW); | ||
} | ||
|
||
void loop() { | ||
// put your main code here, to run repeatedly: | ||
int buttonState = digitalRead(kSwitchPin); | ||
//Serial.print("buttonState: "); | ||
//Serial.println(buttonState); | ||
if (buttonState != gLastButtonState) { | ||
//Serial.println("Setting gLastSwitchTime"); | ||
gLastSwitchTime = millis(); | ||
gLastButtonState = buttonState; | ||
} | ||
|
||
if ((millis() - gLastSwitchTime) > kDebounceDelay) { | ||
// We've got a button press | ||
//Serial.println("Switching..."); | ||
|
||
if (buttonState == HIGH) { | ||
// It's a press | ||
//Serial.print("Changing heating state to "); | ||
gHeatingState = !gHeatingState; | ||
//Serial.println(gHeatingState); | ||
} | ||
} | ||
|
||
digitalWrite(kHeatingPin, gHeatingState); | ||
digitalWrite(kIndicatorPin, gHeatingState); | ||
|
||
delay(10); | ||
} |