Browse Source

Added basic handling of door sensor code

master
Mike C 6 years ago
parent
commit
77615d691a
  1. 6
      src/src.ino

6
src/src.ino

@ -33,6 +33,7 @@ Adafruit_NeoPixel neopix = Adafruit_NeoPixel(NEO_PIX_NUM, PIN_NEO, NEO_GRB + NEO
uint8_t rgb[3]; // index 0 = red / index 1 = green / index 2 = blue
bool white = false;
bool max_found = false;
bool door_open = false;
// Various function definitions
void hsvToRgb(int h, double s, double v); // See end of file for implementation
@ -97,6 +98,7 @@ void loop() {
raw_color = analogRead(POT_COLOR); // Color (0-1024)
always_on = (digitalRead(PIN_ALWAYS_ON) == HIGH); // Toggle button pressed == ALWAYS ON
white = (digitalRead(PIN_WHITE) == HIGH); // Shorted pin to enable white color for LEDs
door_open = (digitalRead(PIN_DOOR == HIGH)); // SparkFun door sensor is indicating door is open (NO for door closed state)
// Set RGB array to values as appropriate
if (white) {
@ -142,12 +144,14 @@ void loop() {
Serial.println(rgb[2]);
Serial.print("Always on: ");
Serial.println(always_on);
Serial.print("Door sensor: ");
Serial.println(door_open);
Serial.println("----------");
delay(250);
}
// Sleep mode enabled
if (USE_SLEEP && !always_on) { // Don't enable sleep if always on toggle is set
if (USE_SLEEP && !always_on && !door_open) { // Don't enable sleep if always on toggle is set
if (DEBUG) {
Serial.println("SLEEPING!");
}

Loading…
Cancel
Save