From reset, digitalWrite to LEDR, LEDB and LEDG works as expected after the appropriate pinMode commands are issued. THEN analogWrite to any or all of those pins also works as expected. THEN, however, going back to digitalWrite (LEDR, LOW) (for example) leaves the LEDs with (apparently) the PWM that was in place when the analogWrite command was executed. In desperation, I added this (in an attempt to restore the original conditions before a subsequent digitalWrite):
void RGBLedsOff()
{
pinMode(LEDR, INPUT);
pinMode(LEDG, INPUT);
pinMode(LEDB, INPUT);
pinMode(LEDR, OUTPUT);
pinMode(LEDG, OUTPUT);
pinMode(LEDB, OUTPUT);
digitalWrite(LEDR, HIGH);
digitalWrite(LEDG, HIGH);
digitalWrite(LEDB, HIGH);
Serial.println ("RGBLedsOff");
}
only to find that the LEDs are still on (lit) with the last PWM values.
Is it possible to disconnect the PWM from the 3 colour LED after it has been connected?