From 11c3cfdb4dc0de022a393de4a7e9cecf7a61c7e7 Mon Sep 17 00:00:00 2001 From: Marco Platino <155002190+MarcoPlatino@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:25:53 -0400 Subject: [PATCH 1/2] Update FredLightingCopy.ino This is the cutting edge (non-working) version --- FredLightingCopy.ino | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/FredLightingCopy.ino b/FredLightingCopy.ino index de859f4..15e16e0 100644 --- a/FredLightingCopy.ino +++ b/FredLightingCopy.ino @@ -1,4 +1,4 @@ -//Absolute version on the collar as of 3-24-2026! +//Current version on the collar as of 3-19-2026! #include #define PIN 3 @@ -16,23 +16,30 @@ int blue[56]; int select = 0; int i,j; int element[8][3]; - +boolean change; void setup() { // put your setup code here, to run once: strip.begin(); strip.show(); // Initialize all pixels to 'off' + change = false; randomSeed(analogRead(A1)); } boolean check(){ - boolean change = false; int sensorValue=analogRead(sensorPin); - if (sensorValue < 512) {select++; change = true;} + if (sensorValue < 512 && !change) { + change = true; + select++; + } else { + + change = false; + + } + if (select > 4) select = 0; - delay(67); return change; } @@ -130,7 +137,7 @@ void loop() { else if (select == 3) blueBandTask(i); else if (select == 4) redBandTask(i); if (check()) {clearStrip(); break;} - delay(20); + delay(18); } } @@ -142,4 +149,4 @@ void loop() { -int cigarettes = 500; +int cigarettes = 0; From 38fa01848e9fe921ebc91f2abe310ad1d07fec89 Mon Sep 17 00:00:00 2001 From: Gleep <145697933+gecko45812@users.noreply.github.com> Date: Tue, 24 Mar 2026 20:01:37 -0400 Subject: [PATCH 2/2] Update FredLightingCopy.ino --- FredLightingCopy.ino | 165 ++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 112 deletions(-) diff --git a/FredLightingCopy.ino b/FredLightingCopy.ino index 15e16e0..332424b 100644 --- a/FredLightingCopy.ino +++ b/FredLightingCopy.ino @@ -1,152 +1,93 @@ -//Current version on the collar as of 3-19-2026! +// Final "Halt on Press" Version - 3-19-2026 #include #define PIN 3 #define NUM_OF_LEDS 56 -Adafruit_NeoPixel strip = Adafruit_NeoPixel(56, PIN, NEO_GRB + NEO_KHZ800); +Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_OF_LEDS, PIN, NEO_GRB + NEO_KHZ800); - -int randomNumber; -int red[56]; -int green[56]; -int blue[56]; - int sensorPin = A0; - int sensorValue = 0; - int select = 0; - int i,j; - int element[8][3]; -boolean change; +int red[56], green[56], blue[56]; +int sensorPin = A0; +int select = 0; void setup() { - // put your setup code here, to run once: - strip.begin(); - strip.show(); // Initialize all pixels to 'off' - change = false; - - - randomSeed(analogRead(A1)); + strip.begin(); + strip.setBrightness(140); + strip.show(); + randomSeed(analogRead(A1)); } -boolean check(){ - int sensorValue=analogRead(sensorPin); - if (sensorValue < 512 && !change) { - change = true; +// This function now only handles the MODE SWAP after release +boolean check() { + if (analogRead(sensorPin) < 512) { + // Wait until released + while (analogRead(sensorPin) < 512) { + delay(10); + } + + // Advance mode select++; - } else { - - change = false; + if (select > 4) select = 0; + delay(50); // Small debounce + return true; } - - if (select > 4) select = 0; - return change; + return false; } - - -void clearStrip(){ - for (int i = 0; i < NUM_OF_LEDS; i++){ - strip.setPixelColor(i, 0, 0, 0); +void clearStrip() { + for (int k = 0; k < NUM_OF_LEDS; k++) { + strip.setPixelColor(k, 0, 0, 0); } strip.show(); } -void greenChaserTask(int i){ +void greenChaserTask(int i) { int chaser_len = 5; - strip.setPixelColor(i, 0, 125, 0); - - if (i < chaser_len) { - - strip.setPixelColor((i-chaser_len+56)%56, 0, 0, 0); - - } - - strip.setPixelColor(i-chaser_len, 0, 0, 0); - strip.setBrightness(140); + // Modulo prevents negative index crashes + strip.setPixelColor((i - chaser_len + NUM_OF_LEDS) % NUM_OF_LEDS, 0, 0, 0); strip.show(); } -void randomLightsTask(int i){ - if (i == 0){ +void randomLightsTask(int i) { + if (i == 0) { for (int r = 0; r < 56; r++) { - red[r] = random(255); - } - - for (int g = 0; g < 56; g++) { - green[g] = random(255); - } - - for (int b = 0; b < 56; b++) { - blue[b] = random(255); + red[r] = random(255); + green[r] = random(255); + blue[r] = random(255); } } - strip.setPixelColor(i, red[i], green[i], blue[i]); - - for (int r = 0; r < 56; r++) { - red[r] -= 4; - } - - for (int g = 0; g < 56; g++) { - green[g] -= 4; - } - - for (int b = 0; b < 56; b++) { - blue[b] -= 4; + for (int k = 0; k < 56; k++) { + if(red[k] > 4) red[k] -= 4; + if(green[k] > 4) green[k] -= 4; + if(blue[k] > 4) blue[k] -= 4; } - - strip.setBrightness(140); strip.show(); } -void colorBandTask(int i, int r, int g, int b){ - strip.setPixelColor(i, r, g, b); - strip.setBrightness(140); - strip.show(); -} - -void greenBandTask(int i){ - colorBandTask(i, 0, 255, 0); -} - -void redBandTask(int i){ - colorBandTask(i, 255, 0, 0); -} - -void blueBandTask(int i){ - colorBandTask(i, 0, 0, 255); +void colorBandTask(int i, int r, int g, int b) { + strip.setPixelColor(i, r, g, b); + strip.show(); } - void loop() { - // put your main code here, to run repeatedly: - - /* Read Sensor - Sensor value will be 1023 when open, - will drop to 78 when blocked - When sensor is blocked, advance slection by 1*/ - - /* ALL GREEN */ + for (int i = 0; i < NUM_OF_LEDS; i++) { + + // 1. Check for the press (and hold here) + if (check()) { + clearStrip(); + break; // Exit 'for' loop to start next animation + } - for (i = 0; i < NUM_OF_LEDS; i ++){ + // 2. Run animations ONLY if sensor isn't being held if (select == 0) greenChaserTask(i); else if (select == 1) randomLightsTask(i); - else if (select == 2) greenBandTask(i); - else if (select == 3) blueBandTask(i); - else if (select == 4) redBandTask(i); - if (check()) {clearStrip(); break;} + else if (select == 2) colorBandTask(i, 0, 255, 0); // Green + else if (select == 3) colorBandTask(i, 0, 0, 255); // Blue + else if (select == 4) colorBandTask(i, 255, 0, 0); // Red + delay(18); - } - } - - - - - - - - -int cigarettes = 0; +}