I am trying to program 2 RGB LEDs so that they light up different colours depending on a potentiometer reading. I have created arrays for each of the 6 cases but when I upload the code, one LED shines red and the other shines green no matter where I turn the Potentiometer. I tried printing the pot output to verify that the values are between 0 and 60 and they are. Can anyone spot my error? Thanks for the help!
Can you post your code in code tags please. Can't open .ino files on my tablet. Also post your schematic so we can check the wiring and see what type of Arduino and leds you are using. The forum guide in the sticky post will explain how, pleaset read the whole guide.
This is not how the C language works. You have to use:-
if (10 <= lightVal && lightVal <20)
Or more conventionally
if (lightVal >=10 && lightVal <20)
The && means the logical "and" operator.