#Rotary encoder NeoPixel code

1 messages ยท Page 1 of 1 (latest)

queen smelt
#

@hardy hornet Hello

hardy hornet
#

hello!

#

can you paste full code

queen smelt
#

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.

hardy hornet
#

instead of looping on the buttons, just check them individually

queen smelt
#

Unrelated, when I press the center button, I hear a quiet pulsing tone from somewhere.

hardy hornet
#

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));
  }
queen smelt
#

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.

hardy hornet
#
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.

queen smelt
#

That's acting like it does inside the loop.

#

yeah

#

Ok!

#

Other than the weird audio interference, I got it.

hardy hornet
#

yes. like that.

#

where is sound coming from?

queen smelt
#

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?

hardy hornet
#

it's probably aliens. or the feds parked out front.

queen smelt
#

Oh those guys. Ugh.

hardy hornet
#

just put on a tinfoil hat

queen smelt
#

On it.

hardy hornet
#

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

queen smelt
#

Yeah giving that a try

hardy hornet
#

it may be "flickery"

queen smelt
#

It is!

#

The green LED isn't solid.

#

The others are ok

#

but that one is not

hardy hornet
#

yah, it' because you're spamming updates all through the loop

#

instead of just once at the end

queen smelt
#

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?

hardy hornet
#

hmm....try adding that and going back to auto_write on

queen smelt
#

Now it flickers more slowly ๐Ÿ˜„

#

And the others flicker slowly too

#

So that answers that.

hardy hornet
#

ok. so the spammy updates are noticeable.

queen smelt
#

Yeah.

hardy hornet
#

in that case the delay is only needed to prevent spamming the serial prints

queen smelt
#

I'm not worried about it.

hardy hornet
#

otherwise fine to read and update the neopixels as fast as possible

queen smelt
#

Yeah exactly

#

Alright. I think it's ready for primetime.

#

Thanks so much!