I just experimentet with my new Arduino RP2040 Connect and played with the onboard RGB LED.
When i tried to turn the LEDs on and off using the analogWrite-Function, i noticed a glow of the LEDs when they should have been turned off.
Is this normal or did i miss something? Is this a bug?
/* This sample code shows some behaviour of the RGB-LED (LEDR in example used).
* I'm unable to turn the LEDs off, after activating them with analogWrite(led, 0).
* The LEDs still glow.
* I have to repeat the OUTPUT-assignemnt, to turn them completely off.
* Is this normal?
*/
#include <WiFiNINA.h>
void setup() {
// use LEDR as output
pinMode(LEDR, OUTPUT); //LEDR, LEDG, LEDB
}
void loop() {
// turn LEDR on (max brightness)
analogWrite(LEDR, 0);
delay(1000);
// turn LEDR off (expected: no light at all, found: LEDR still glows)
analogWrite(LEDR, 255);
delay(1000);
// trying to turn LEDR completely off (with digitalwrite)
// doesn't work either, LEDR still glowing
// if LEDR would have been activated by digitalWrite(LEDR, HIGH); this would turn LEDR completely off
digitalWrite(LEDR, LOW);
delay(1000);
// setting LEDR as output (again) and then calling digitalWrite - turns LEDR off
pinMode(LEDR, OUTPUT);
digitalWrite(LEDR, LOW);
delay(1000);
}
First, thank you for providing a small program example that demonstrates the problem. Also for using code tags.
I don't think the problem is in your code. Post a schematic. (NOT a pretty Fritzing picture. Fritzing pictures are not schematics that engineers can read).
Thank you for your reply and your compliments - it's my first post in this forum
I'm just using the Arduino RP2040 Connect without any additional parts - the RGB-LED is onboard.
(Sorry, i forgot to mention "onboard" - i have added this to the original post)
Hmm, i'm not sure.
It also happens with the red LED and there is no wlan traffic which could influence the LEDs. Also switching the LEDs with digitalWrite(LEDR, HIGH/LOW) turns them perfectly on and off without any glowing.