Tell us about yourself!
Easy build. I used an ESP-01 and the fastled library instead. Designed and printed my own caseWorks well, my daughter loves it.Tip: Window tint tubes make excellent led diffusers.
Here is some example code. Not checked for full correctness:
You will need to add constraints on the encoder value to ensure it does not go negative or more than 1023 but keep the interrupt routine(s) as small as possible.
Once again, encoder is not a button, you can't read it like that.Normally, you attach an interrupt onto one of the pins, then in the interrupt routine you check the other pin's state. If it is high, it will be one direction, low, the other.Atmega238 only has 2 interrupt pins (2 and 3). You can move those to A6/7 for the matrix but if you want more than one, then you still need more pins for the 'B' pin on the encoder. These could be sacrificed from the 4 analog inputs.
Well encoders are not buttons - They will always have one contact connected. This code is not designed for encoders.