#Rotary encoder NeoPixel code
1 messages ยท Page 1 of 1 (latest)
Yes.
Actually, I'll send the file. Not sure it'll fit.
I adapted this from some code JP wrote that used Debouncer. Which as convenient as it is, I'm not going to do because it doesn't match the Arduino sketch.
Plus, it only flashes the LED(s) when you press the buttons because it only sees one press.
instead of looping on the buttons, just check them individually
Unrelated, when I press the center button, I hear a quiet pulsing tone from somewhere.
ard skethc for ref:
if (! digitalRead(BUTTON_UP)) {
pixels.setPixelColor(0, pixels.Color(150, 0, 0));
}
if (! digitalRead(BUTTON_LEFT)) {
pixels.setPixelColor(NUMPIXELS/4, pixels.Color(150, 0, 0));
}
if (! digitalRead(BUTTON_DOWN)) {
pixels.setPixelColor(NUMPIXELS/2, pixels.Color(150, 0, 0));
}
if (! digitalRead(BUTTON_RIGHT)) {
pixels.setPixelColor(NUMPIXELS*3/4, pixels.Color(150, 0, 0));
}
if (! digitalRead(BUTTON_IN)) {
pixels.fill(pixels.Color(50, 50, 50));
}
It's in sync with what I assume is the flashing of the LEDs
Can't figure out where the sound is coming from though.
Ok hold on
Oh also that was supposed to be an if not buttons I tried the while to see what it would do.
Ohhhh ok.
if not buttons[0].value:
print("enter")
pixels.fill((100, 100, 100))
if not buttons[1].value:
print("up")
pixels[0] = (150, 0, 0)
etc.
That's acting like it does inside the loop.
yeah
Ok!
Other than the weird audio interference, I got it.
I have no idea.
It's when I press the center button and the LEDs go white.
They're pulsing faster than I can see
but I can hear something
and it doesn't get louder if I move the Feather setup closer to my face
Or I got bitten by something and now I can hear LEDs?
it's probably aliens. or the feds parked out front.
Oh those guys. Ugh.
just put on a tinfoil hat
On it.
you can try your same code with auto_write on and remove the show
just see what it ends up looking like on the neopixels
Yeah giving that a try
it may be "flickery"
yah, it' because you're spamming updates all through the loop
instead of just once at the end
Got it.
Leaving it on.
Much better.
Thank you!
Oh
There's a delay in the sketch
Do I need one in the CP code?
hmm....try adding that and going back to auto_write on
Now it flickers more slowly ๐
And the others flicker slowly too
So that answers that.
ok. so the spammy updates are noticeable.
Yeah.
in that case the delay is only needed to prevent spamming the serial prints
I'm not worried about it.
otherwise fine to read and update the neopixels as fast as possible