From a6468bea150cb584b51b2fde5f4afd31800e320d Mon Sep 17 00:00:00 2001 From: Alain Martel Date: Wed, 13 Nov 2019 21:49:12 -0500 Subject: [PATCH 1/4] Importing Zack's modifications --- GameTimerPro/Hardware.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GameTimerPro/Hardware.h b/GameTimerPro/Hardware.h index 1557384..e7cccf4 100644 --- a/GameTimerPro/Hardware.h +++ b/GameTimerPro/Hardware.h @@ -3,8 +3,9 @@ #define IR_PIN 10 #define SPEAKER_PIN 2 -#define DET_TRIGGER_PIN 7 -#define DEFUSE_TRIGGER_PIN 8 +#define NEOPIXEL_PIN 7 //!!!!THE STABILITY ISSUES (SOMETIMES WONT COMPILE MAY BE CAUSED BY DET_TRIGGER_PIN AND DEFUSE_TRIGGER_PIN BEING COMMENTED OUT THROUGHOUT MAIN SKETCH!!!! +#define DET_TRIGGER_PIN 71 //THIS WAS ORIGINALLY '7' AND IS NOW PASSED INTO THE VOID +#define DEFUSE_TRIGGER_PIN 8 //THIS PIN IS USED TO TRIGGER THE RELAY FOR THE 108dB SIREN #define BUTTON_LEFT_PIN 3 #define BUTTON_SELECT_PIN 5 #define BUTTON_RIGHT_PIN 6 From d11104236df1f80eec11e570d996a5bb8f5ccc93 Mon Sep 17 00:00:00 2001 From: Alain Martel Date: Wed, 13 Nov 2019 22:08:56 -0500 Subject: [PATCH 2/4] Importing Zack's modifications --- GameTimerPro/GameTimerPro.ino | 141 +++++++++++++++++++++++++--------- 1 file changed, 104 insertions(+), 37 deletions(-) diff --git a/GameTimerPro/GameTimerPro.ino b/GameTimerPro/GameTimerPro.ino index 059f156..7e64f41 100644 --- a/GameTimerPro/GameTimerPro.ino +++ b/GameTimerPro/GameTimerPro.ino @@ -1,6 +1,8 @@ +//*************************************THIS CODE LAST MODIFIED 12-27-18 TO COMPLETE THE LIGHT DETONATION CYCLES*********************************************************// +//***https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use #include - +#include #include "Hardware.h" #include "Config.h" #include "Display.h" @@ -10,8 +12,10 @@ #include "Sound.h" #include "LowPower.h" -byte leds[] = {LED1, LED2, LED3, LED4}; -int volume = 10; +byte leds[] = {LED1, LED2, LED3, LED4}; //*********// These are LEDs on the control board itself +int volume = 255; + +Adafruit_NeoPixel strip = Adafruit_NeoPixel(14, NEOPIXEL_PIN); //********// (14 NeoPixels, Controlled through PIN7) Config config = Config(); Display display = Display(); @@ -32,6 +36,9 @@ int defuseWire; int speedupWire; int pauseWire; +uint32_t color = strip.Color(250, 250, 0); //********// Change RGB color value here +//int sine[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; //********// + void setup() { Serial.begin(115200); display.begin(); @@ -53,22 +60,25 @@ void setup() { digitalWrite(DET_TRIGGER_PIN, LOW); digitalWrite(DEFUSE_TRIGGER_PIN, LOW); + strip.begin(); //INITIALIZE NEOPIXELS FOR USE + strip.show(); //SET ALL NEOPIXELS TO OFF BY DEFAULT + if (!((buttonPressed(BUTTON_LEFT)) && (buttonPressed(BUTTON_RIGHT)))) { config.load(); if (!config.valid()) { config.reset(); - beep(2000, 20, 10); + beep(2000, 20, 10); //FREQUENCY, DURATION, VOLUME delay(50); - beep(2000, 20, 10); + beep(2000, 20, 10); //FREQUENCY, DURATION, VOLUME delay(50); - beep(2000, 20, 10); + beep(2000, 20, 10); //FREQUENCY, DURATION, VOLUME } } else { // Factory reset config.reset(); - beep(2000, 20, 10); + beep(2000, 20, 10); //FREQUENCY, DURATION, VOLUME delay(50); - beep(2000, 20, 10); + beep(2000, 20, 10); //FREQUENCY, DURATION, VOLUME while ((buttonPressed(BUTTON_LEFT)) || (buttonPressed(BUTTON_RIGHT))); } @@ -608,12 +618,28 @@ void detonate() { triggerStart = millis(); triggerStop = triggerStart + (config.get(DET_TRIGGER_SEC) * 1000UL); if (triggerStop > triggerStart) { - digitalWrite(DET_TRIGGER_PIN, HIGH); - } + //digitalWrite(PIN8, HIGH); //****************************DETONATION FUNCTION**************************************************************// + theaterChase(strip.Color(255, 255, 0), 70); //YELLOW //(GREEN, RED, BLUE), SECOND VARIABLE IS SPEED OF CYCLE - HIGHER NUMBER IS SLOWER + theaterChase(strip.Color(69, 255, 0), 55); //ORANGE + theaterChase(strip.Color(0, 255, 0), 40); //RED + digitalWrite(DEFUSE_TRIGGER_PIN, HIGH); //THIS LINE TRIGGERS THE 108Db SIREN + for(int j=0; j<60; j++) { //j IS EQUIVALENT TO ROUGHLY 1 SECOND, j=300 IS ROUGHLY 5 MINUTES + colorWipe(strip.Color(0, 255, 0), 9); //RED (255,0,0)=GREEN, (0,255,0)=RED, (0,0,255)=BLUE, https://www.rapidtables.com/web/color/RGB_Color.html + colorWipe(strip.Color(69, 255, 0), 4); //ORANGE ***SECOND VARIABLE CHANGES HOW QUICKLY CYCLE WIPES*** + colorWipe(strip.Color(220, 220, 220), 2); //OFF-WHITE + colorWipe(strip.Color(0, 255, 0), 6); //RED + colorWipe(strip.Color(69, 255, 0), 3); //ORANGE + colorWipe(strip.Color(192, 255, 203), 1); //PINK + colorWipe(strip.Color(0, 255, 0), 3); //RED + colorWipe(strip.Color(69, 255, 0), 2); //ORANGE + colorWipe(strip.Color(255, 255, 255), 1); //WHITE ***THIS IS THE COLOR THAT WILL HOLD WHILE THE BOARD RESETS IN THE LOOP BELOW*** + } + } display.setDisplayColon(false); for(int i=0;i= triggerStop) { - digitalWrite(DET_TRIGGER_PIN, LOW); + digitalWrite(DEFUSE_TRIGGER_PIN, LOW); + //digitalWrite(DET_TRIGGER_PIN, LOW); } display.setDigitRaw(1, random(255)); display.setDigitRaw(2, random(255)); @@ -622,12 +648,13 @@ void detonate() { display.setDigitRaw(0, random(255) << 8); display.update(); for (int j = 0; j < 5; j++) { - if (millis() >= triggerStop) { - digitalWrite(DET_TRIGGER_PIN, LOW); - } + //if (millis() >= triggerStop) { + // digitalWrite(DET_TRIGGER_PIN, LOW); + //} beep(random(100, 300), 10, 10); } } + theaterChase(strip.Color(0, 0, 0), 0); //***********FUNCTION CALL FOR BLANKING OUT NEOPIXELS AT THE END OF DETONATION***********// display.clear(); for(byte i=0;i<4;i++) { display.setLED(leds[i], LOW); @@ -639,20 +666,27 @@ void detonate() { display.setLED(LED2, HIGH); // reset countdown while (true) { - if (millis() >= triggerStop) { - digitalWrite(DET_TRIGGER_PIN, LOW); - } + //if (millis() >= triggerStop) { + // digitalWrite(DET_TRIGGER_PIN, LOW); + //} // wait for button press or IR select command + colorWipe(strip.Color(0, 255, 0), 9); //HOLD RED PATTERN UNTIL BUTTON OR IR RESET irCommand = ir.getIRCommand(); - if ((irCommand == IR_SELECT) || (irCommand == IR_SELECT2)) break; - if (buttonPressed(BUTTON_DET)) break; + if (irCommand == IR_SELECT) { + theaterChase(strip.Color(0, 0, 0), 0); //BLANK OUT NEOPIXELS ON IR SELECT + break; + } + if (buttonPressed(BUTTON_DET)) { + theaterChase(strip.Color(0, 0, 0), 0); //BLANK OUT NEOPIXELS ON IR SELECT + break; + } delay(20); } delay(20); while (true) { - if (millis() >= triggerStop) { - digitalWrite(DET_TRIGGER_PIN, LOW); - } + //if (millis() >= triggerStop) { + // digitalWrite(DET_TRIGGER_PIN, LOW); + //} // wait for button release if ((irCommand == IR_SELECT) || (irCommand == IR_SELECT2)) break; // remote was used if (!buttonPressed(BUTTON_DET)) break; @@ -663,7 +697,7 @@ void detonate() { countdownSeconds = config.get(COUNTDOWN_DURATION); } -void defused() { +void defused() { //********************************************DEFUSAL INSTRUCTIONS******************************************// unsigned long irCommand; unsigned long triggerStart; unsigned long triggerStop; @@ -675,7 +709,12 @@ void defused() { triggerStart = millis(); triggerStop = triggerStart + (config.get(DEFUSE_TRIGGER_SEC) * 1000UL); if (triggerStop > triggerStart) { - digitalWrite(DEFUSE_TRIGGER_PIN, HIGH); + //digitalWrite(DEFUSE_TRIGGER_PIN, HIGH); + for(int j=0; j<15; j++) { //EACH j EQUATES TO ROUGHLY 5.5sec, 5 MINUTES IS ROUGHLY j=55 + theaterChase(strip.Color(255, 0, 0), 60); //GREEN(GREEN, RED, BLUE), SECOND VARIABLE IS SPEED OF CYCLE - HIGHER NUMBER IS SLOWER + theaterChase(strip.Color(255, 0, 128), 60); //BLUE GREEN + theaterChase(strip.Color(255, 128, 0), 60); //YELLOW GREEN + } } delay(50); for(byte i=0;i<4;i++) { @@ -684,9 +723,9 @@ void defused() { int successCode = config.get(SUCCESS_CODE); if (successCode != UNSET) { for(byte i=0;i<50;i++) { - if (millis() >= triggerStop) { - digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - } + //if (millis() >= triggerStop) { + // digitalWrite(DEFUSE_TRIGGER_PIN, LOW); + //} delay(20); } display.setDisplayColon(false); @@ -704,27 +743,33 @@ void defused() { delay(250); display.setLED(LED2, HIGH); while (true) { - if (millis() >= triggerStop) { - digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - } - // wait for button press or IR select command + //if (millis() >= triggerStop) { + // digitalWrite(DEFUSE_TRIGGER_PIN, LOW); + //} + colorWipe(strip.Color(255, 0, 0), 9); //HOLD GREEN PATTERN UNTIL BUTTON OR IR RESET irCommand = ir.getIRCommand(); - if ((irCommand == IR_SELECT) || (irCommand == IR_SELECT2)) break; - if (buttonPressed(BUTTON_DET)) break; + if (irCommand == IR_SELECT) { + theaterChase(strip.Color(0, 0, 0), 0); //BLANK OUT NEOPIXELS ON IR SELECT + break; + } + if (buttonPressed(BUTTON_DET)) { + theaterChase(strip.Color(0, 0, 0), 0); //BLANK OUT NEOPIXELS ON BUTTON SELECT + break; + } delay(20); } delay(20); while (true) { - if (millis() >= triggerStop) { - digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - } + //if (millis() >= triggerStop) { + // digitalWrite(DEFUSE_TRIGGER_PIN, LOW); + //} // wait for button release if ((irCommand == IR_SELECT) || (irCommand == IR_SELECT2)) break; // from last check if (!buttonPressed(BUTTON_DET)) break; delay(20); } display.setLED(LED2, LOW); - digitalWrite(DEFUSE_TRIGGER_PIN, LOW); + //digitalWrite(DEFUSE_TRIGGER_PIN, LOW); countdownSeconds = config.get(COUNTDOWN_DURATION); } @@ -742,6 +787,28 @@ void configure() { } } +void colorWipe(uint32_t c, uint8_t wait) { //********FILLS PIXELS ONE AFTER ANOTHER WITH PASSED COLOR********// + for(uint16_t i=0; i<30; i++) { //'i' VALUE CHANGES SPEED OF WIPE ACTION + strip.setPixelColor(i, c); + strip.show(); + delay(wait); + } +} + +void theaterChase(uint32_t c, uint8_t wait) { //********THEATER CHASE FUNCTION********// + for (int j=0; j<10; j++) { //'j' VALUE CHANGES HOW LONG THE FUNCTION CYCLES FOR + for (int q=0; q<3; q++) { + for (uint16_t i=0; i Date: Wed, 13 Nov 2019 22:25:42 -0500 Subject: [PATCH 3/4] Removed commented out code Mainly references to DET_TRIGGER_PIN --- GameTimerPro/GameTimerPro.ino | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/GameTimerPro/GameTimerPro.ino b/GameTimerPro/GameTimerPro.ino index 7e64f41..bbc7520 100644 --- a/GameTimerPro/GameTimerPro.ino +++ b/GameTimerPro/GameTimerPro.ino @@ -37,7 +37,6 @@ int speedupWire; int pauseWire; uint32_t color = strip.Color(250, 250, 0); //********// Change RGB color value here -//int sine[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; //********// void setup() { Serial.begin(115200); @@ -45,7 +44,6 @@ void setup() { ir.begin(); pinMode(SPEAKER_PIN, OUTPUT); - pinMode(DET_TRIGGER_PIN, OUTPUT); pinMode(DEFUSE_TRIGGER_PIN, OUTPUT); pinMode(BUTTON_LEFT_PIN, INPUT_PULLUP); pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP); @@ -57,7 +55,6 @@ void setup() { pinMode(WIRE4_PIN, INPUT_PULLUP); digitalWrite(SPEAKER_PIN, LOW); - digitalWrite(DET_TRIGGER_PIN, LOW); digitalWrite(DEFUSE_TRIGGER_PIN, LOW); strip.begin(); //INITIALIZE NEOPIXELS FOR USE @@ -618,7 +615,7 @@ void detonate() { triggerStart = millis(); triggerStop = triggerStart + (config.get(DET_TRIGGER_SEC) * 1000UL); if (triggerStop > triggerStart) { - //digitalWrite(PIN8, HIGH); //****************************DETONATION FUNCTION**************************************************************// + //****************************DETONATION FUNCTION**************************************************************// theaterChase(strip.Color(255, 255, 0), 70); //YELLOW //(GREEN, RED, BLUE), SECOND VARIABLE IS SPEED OF CYCLE - HIGHER NUMBER IS SLOWER theaterChase(strip.Color(69, 255, 0), 55); //ORANGE theaterChase(strip.Color(0, 255, 0), 40); //RED @@ -639,7 +636,6 @@ void detonate() { for(int i=0;i= triggerStop) { digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - //digitalWrite(DET_TRIGGER_PIN, LOW); } display.setDigitRaw(1, random(255)); display.setDigitRaw(2, random(255)); @@ -648,9 +644,6 @@ void detonate() { display.setDigitRaw(0, random(255) << 8); display.update(); for (int j = 0; j < 5; j++) { - //if (millis() >= triggerStop) { - // digitalWrite(DET_TRIGGER_PIN, LOW); - //} beep(random(100, 300), 10, 10); } } @@ -666,9 +659,6 @@ void detonate() { display.setLED(LED2, HIGH); // reset countdown while (true) { - //if (millis() >= triggerStop) { - // digitalWrite(DET_TRIGGER_PIN, LOW); - //} // wait for button press or IR select command colorWipe(strip.Color(0, 255, 0), 9); //HOLD RED PATTERN UNTIL BUTTON OR IR RESET irCommand = ir.getIRCommand(); @@ -684,9 +674,6 @@ void detonate() { } delay(20); while (true) { - //if (millis() >= triggerStop) { - // digitalWrite(DET_TRIGGER_PIN, LOW); - //} // wait for button release if ((irCommand == IR_SELECT) || (irCommand == IR_SELECT2)) break; // remote was used if (!buttonPressed(BUTTON_DET)) break; @@ -709,7 +696,6 @@ void defused() { //********************************************DEFUSAL INSTRUCT triggerStart = millis(); triggerStop = triggerStart + (config.get(DEFUSE_TRIGGER_SEC) * 1000UL); if (triggerStop > triggerStart) { - //digitalWrite(DEFUSE_TRIGGER_PIN, HIGH); for(int j=0; j<15; j++) { //EACH j EQUATES TO ROUGHLY 5.5sec, 5 MINUTES IS ROUGHLY j=55 theaterChase(strip.Color(255, 0, 0), 60); //GREEN(GREEN, RED, BLUE), SECOND VARIABLE IS SPEED OF CYCLE - HIGHER NUMBER IS SLOWER theaterChase(strip.Color(255, 0, 128), 60); //BLUE GREEN @@ -723,9 +709,6 @@ void defused() { //********************************************DEFUSAL INSTRUCT int successCode = config.get(SUCCESS_CODE); if (successCode != UNSET) { for(byte i=0;i<50;i++) { - //if (millis() >= triggerStop) { - // digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - //} delay(20); } display.setDisplayColon(false); @@ -743,9 +726,6 @@ void defused() { //********************************************DEFUSAL INSTRUCT delay(250); display.setLED(LED2, HIGH); while (true) { - //if (millis() >= triggerStop) { - // digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - //} colorWipe(strip.Color(255, 0, 0), 9); //HOLD GREEN PATTERN UNTIL BUTTON OR IR RESET irCommand = ir.getIRCommand(); if (irCommand == IR_SELECT) { @@ -760,16 +740,12 @@ void defused() { //********************************************DEFUSAL INSTRUCT } delay(20); while (true) { - //if (millis() >= triggerStop) { - // digitalWrite(DEFUSE_TRIGGER_PIN, LOW); - //} // wait for button release if ((irCommand == IR_SELECT) || (irCommand == IR_SELECT2)) break; // from last check if (!buttonPressed(BUTTON_DET)) break; delay(20); } display.setLED(LED2, LOW); - //digitalWrite(DEFUSE_TRIGGER_PIN, LOW); countdownSeconds = config.get(COUNTDOWN_DURATION); } From 479a17e12215861e426eaacb64e04b01125bac84 Mon Sep 17 00:00:00 2001 From: Alain Martel Date: Wed, 13 Nov 2019 22:28:23 -0500 Subject: [PATCH 4/4] Removed commented out code Mainly references to DET_TRIGGER_PIN --- GameTimerPro/Hardware.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GameTimerPro/Hardware.h b/GameTimerPro/Hardware.h index e7cccf4..6485050 100644 --- a/GameTimerPro/Hardware.h +++ b/GameTimerPro/Hardware.h @@ -3,8 +3,7 @@ #define IR_PIN 10 #define SPEAKER_PIN 2 -#define NEOPIXEL_PIN 7 //!!!!THE STABILITY ISSUES (SOMETIMES WONT COMPILE MAY BE CAUSED BY DET_TRIGGER_PIN AND DEFUSE_TRIGGER_PIN BEING COMMENTED OUT THROUGHOUT MAIN SKETCH!!!! -#define DET_TRIGGER_PIN 71 //THIS WAS ORIGINALLY '7' AND IS NOW PASSED INTO THE VOID +#define NEOPIXEL_PIN 7 //!!!!THE STABILITY ISSUES (SOMETIMES WONT COMPILE)!!!! #define DEFUSE_TRIGGER_PIN 8 //THIS PIN IS USED TO TRIGGER THE RELAY FOR THE 108dB SIREN #define BUTTON_LEFT_PIN 3 #define BUTTON_SELECT_PIN 5