A post in which I explain that my short term memory resembles that of a goldfish.
Apologies for the skimpy post this week. It takes me 100 times longer than a normal human to program something because I keep forgetting how code works. Slow pace = small result.
Programming Schmogramming
So I’ve been trying to write the part of the code that takes the accelerometer data and uses it as an input to change the color and intensity of the NeoPixels. I’ve managed to turn this into a fun marriage-straining exercise in which I just try out whatever I think will work and then ask my spouse for the correct way of doing it. I think he’s getting frustrated with me. He said that it’s like I’m trying to write a novel without being able to read a sentence. This is probably true. But, as I told him, sometimes it’s more motivating to shoot for the complex and crazy, even when it’s utterly unrealistic.
An Approach
I like to think on paper so I wrote out a little blurb on how I want the accelerometer to interact with the NeoPixels: There are two aspects of the NeoPixels that will change: color and intensity. So the program needs “boxes” for those two things and then it needs to always push these values out to the LEDs. The information from the accelerometer changes whatever is in the boxes for color and intensity. The intensity starts at 0 and the color starts at whatever value is furthest from red (I think purple on the hue scale). Then, when there is an accelerometer event powerful enough to trigger it, the intensity increases by 10 and the color increases by 10 (these values will all get finessed). Then there needs to be some kind of time-based fade-out. If another event occurs before the end of the fade-out then the color/intensity increase will be added to its current state is.
I’m not sure if that will really make sense to anyone else but it’s what I’ve been working with in my fun trial-and-error way. Rather than use the serial debugging, I ended up just hooking up a NeoPixel and trying things out as I go.
Piddling Progress
As of right now, I’ve gotten the light to increase intensity by 10 anytime there’s movement above a certain threshold (aka when the vector length of the combined x,y,z values is more than 4000). The concept that keeps tripping me up is that a variable’s name isn’t the thing itself but rather a container called the thing. So when I make something called “current_brightness” I can just keep putting different values inside of it (current_brightness = current_brightness + 10 = MIND BLOWN). I have to continually remind myself that this is not a symbol language; it’s more like labeling a bunch of drawers and boxes. But I’m basically like that guy from Memento with anterograde amnesia, thereby working at a snail’s pace and torturing my spouse in a fun new way as he attempts to help me without helping too much.
As riveting as you must find this, I’m really hoping to step it up this weekend. For reading this far, I reward you with a picture of a pretty yellow fascinator that I spotted yesterday: