I am using the Arduino MEGA 2560. I have two pots wired up, to the A0 and A1 pins. They are to control the brightness of two separate LED Strips of different types. One is a WS2812 strip, which I am using the FastLED Library to drive. They are working just fine. The other strip are just generic 5050 package LEDs. I am driving them through just a simple transistor. They are also working fine when they are being driven. Everything was working beautifully, the physical side of everything is still working perfectly. But all of a sudden I was getting unexpected behavior on the WS2812s. So I use serial to debug and I can see that analogRead on the pots are coming back as expected between 0-1023 and fully responsive, but to drive the LEDs I need a value between 0-255 so I am just using the binary operator >> 2 to scale it. My issue is that for one of the pots I am getting a value around 10000 after the binary shift instead of between 0-255. When putting this into the LEDs, this is what was causing the issues with WS2812. I tied the brightness to the other pot signal and it is working beautifully. Is this a common issue? I can't seem to change the value from the 10000 range, not even by defining it as zero right before the Serial Print line. I would post the code, but it is all in a LONG file, where I am doing many other things. I am just hoping someone has had this issue before and can help me debug.
I'm going to guess you are mixing & matching data types and somehow some bits are getting shifted-in from the left.
Normally you can shift (left or right) until there is nothing but zeros and if you keep shifting every bit is still zero.
Have you tried dividing by 4? The compiler might be smart enough to do a bit-shift (or whatever is the most efficient).
And "just for fun" you might want to open the Windows calculator in programmer mode and type-in the exact number that's near 10,000 to see what it is in binary.
My thoughts, also. But if his storage int is defined in a function with no beginning value, the beginning value could be anything. Still waiting for code!