manymanywtf
Member
Hi. Background: I was sort of involuntarily tasked with the LED lighting for an art project I'm doing with some friends. I don't have hardly any coding experience, thus I'm trying to use some AI assistants (have tried ChatGPT and Claude) for help, and very disappointed with the results, to say the least. I can read the code a bit and sometimes have an idea of what's going on but it is taking a really, really, really long time for very little progress. I'm sure many would judge this as an overly ambitious project for a first-timer but I am who I am and the project is the project. Can't change either, really. Anyway.
I'm doing a Hueshift on one Teensy and I'm trying to send a GPIO High signal to the other Teensys when the Hueshift loops back to '0', so that the other Teensys keep their Hue shift in sync. You might ask why I am not using Serial and that's because I couldn't get it to work for some reason. GPIO is working great, however.
This is the latest of what ChatGPT is trying to do (paraphrasing the entire code for just the HueShift bits):
int hueShift = 0; // Start hue rotation at Blue (0 degrees in the HSV color space)
int previousHueShift = 255; // Track the previous value of hueShift to detect reset
bool isHueReset = false; // Flag to track if hueShift reset from 255 to 0
// Send the Hue sync signal only when hueShift goes from 255 to 0
if (hueShift == 0 && previousHueShift == 255 && !isHueReset) {
digitalWrite(21, HIGH); // Send trigger to Teensy 2
delay(50); // Ensure the signal is received
digitalWrite(21, LOW); // Reset GPIO pin for Teensy 2
isHueReset = true; // Mark that the reset has been triggered
}
// Reset isHueReset flag when hueShift reaches 255 (so we can trigger it again)
if (hueShift == 255) {
isHueReset = false; // Ready to send signal again when hue resets to 0
}
// Increment hue for color rotation
hueShift++; // Slowly increment the hue value for color transition (rotate through hues)
if (hueShift > 255) {
hueShift = 0; // Reset hue to blue when it exceeds the max value
}
previousHueShift = hueShift; // Track previous hueShift value
}
Every variation of this code that is tried is the same result: The Teensy is sending the High signal for every incremental change of HueShift, not just when it resets back to '0'.
So what's wrong? Spent all day trying to solve this, I'm ready to shortcut this, ha. Thanks for any help and apologies for the remedial user here, ha.
I'm doing a Hueshift on one Teensy and I'm trying to send a GPIO High signal to the other Teensys when the Hueshift loops back to '0', so that the other Teensys keep their Hue shift in sync. You might ask why I am not using Serial and that's because I couldn't get it to work for some reason. GPIO is working great, however.
This is the latest of what ChatGPT is trying to do (paraphrasing the entire code for just the HueShift bits):
int hueShift = 0; // Start hue rotation at Blue (0 degrees in the HSV color space)
int previousHueShift = 255; // Track the previous value of hueShift to detect reset
bool isHueReset = false; // Flag to track if hueShift reset from 255 to 0
// Send the Hue sync signal only when hueShift goes from 255 to 0
if (hueShift == 0 && previousHueShift == 255 && !isHueReset) {
digitalWrite(21, HIGH); // Send trigger to Teensy 2
delay(50); // Ensure the signal is received
digitalWrite(21, LOW); // Reset GPIO pin for Teensy 2
isHueReset = true; // Mark that the reset has been triggered
}
// Reset isHueReset flag when hueShift reaches 255 (so we can trigger it again)
if (hueShift == 255) {
isHueReset = false; // Ready to send signal again when hue resets to 0
}
// Increment hue for color rotation
hueShift++; // Slowly increment the hue value for color transition (rotate through hues)
if (hueShift > 255) {
hueShift = 0; // Reset hue to blue when it exceeds the max value
}
previousHueShift = hueShift; // Track previous hueShift value
}
Every variation of this code that is tried is the same result: The Teensy is sending the High signal for every incremental change of HueShift, not just when it resets back to '0'.
So what's wrong? Spent all day trying to solve this, I'm ready to shortcut this, ha. Thanks for any help and apologies for the remedial user here, ha.