I've just started tinkering with arduinos and my experience level is sufficiently low when it comes to the hardware side in general. I'm a software developer by trade, so I do understand the programming part of it (to a certain degree I guess).
Please don't hold back on the technical details
I've started tinkering with LEDs using three of the PWM pins on a Nano 33 BLE board (specifically 9, 10, 11).
And everything was working so far. Did some rainbow transitions, etc just to get used to using the pins.
Now I wanted to compare two different rainbow transitions and tried to add a second LED. I checked which other pins would be PWM and found 3, 5 and 6.
To start with I just tried to turn on both LEDs, but after the 4th analogWrite, the 5th just won't work and the Arduino seems to be stuck (have to double press reset to upload a new program).
I'm stumped as to why this might be happening.
analogWrite(D3, 255); // LED1 - Red analogWrite(D5, 255); // LED1 - Green analogWrite(D6, 255); // LED1 - Blue analogWrite(D9, 255); // LED2 - Red analogWrite(D10, 255); // LED2 - Green analogWrite(D11, 255); // LED2 - Blue
I'm using 255s, to use the resulting color of the RGB LEDs to see when it's failing.
If I use digitalWrite([...], HIGH), both LEDs are white, but with digital write, LED1 is white, while LED2 stays red.
If I mix up the statements, it's always the 5th analog write that is causing the arduino to be stuck.