0

I have an RGB LED hooked up to pins 7,8 and 9 on my Elegoo Mega2560. If I apply analogWrite(, 255) to each pin, I get a white light as expected. However, if instead, I apply analogWrite(, 225) to each pin, I get a yellow light, as if the blue pin 9 is LOW. To confirm, if I physically disconnect pin 9, it makes no difference to the light.

In case this is a library/timer issue, my sketch is also using the membrane keypad library and the IR Receiver library.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Give normal readable code, not story – Jacek Cz Aug 12 '17 at 15:18
  • @JacekCz welcome to StackOverflow. My code is one line, analogWrite(9,225). Would you like me to copy paste all of the third party library code into my question, and if, so please explain how that helps. Note that there is an accepted answer. – pinoyyid Aug 12 '17 at 17:28

1 Answers1

1

The IR Receiver library probably uses a timer. See which timer it uses and make sure it isn't the same timer that controls PWM on pin 9.

Delta_G
  • 2,927
  • 2
  • 9
  • 15
  • thx. Is there a reference for which pins are affected by which timers? – pinoyyid Aug 12 '17 at 17:24
  • No. Certain pins are just controlled by certain timers. It's in the hardware and they can't be changed. You might be able to change which timer that library uses. But it is probably easier to just pick a different pin for the led. – Delta_G Aug 12 '17 at 20:10