On another thread I have mentioned something about the LEDR, LEDG, LEDB and LED_BUILTIN being hard wired to 3V3 meaning to turn them on you need to send a LOW to ground the circuit. Example:
digitalWrite(LED_BUILTIN, LOW). Weird but I can work with that. From a board manufacture point of view this probably makes sense, no one is connecting the incorrect voltage to the LED, frying it.
So now I am messing around with trying to control the strength of the on board LED using analogWrite.
Does anyone have working code, to control the brightness of the on board LED? My attempts seem to stress out the board and throw it into panic mode (flashing red LED), which needs a double button push to force bootloader and often crashes my Ubuntu machine.
I have managed to get the onboard LED to fade using delayMicrosecond, but that is not really the point.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
int j=1;
void loop() {
j += 1;
if (j > 1000){
j= 1;
digitalWrite(LED_BUILTIN, 1); // LED off
delay(1000);
}
digitalWrite(LED_BUILTIN, 0); // LED on
delayMicroseconds(j); // wait
digitalWrite(LED_BUILTIN, 1); // LED off
delayMicroseconds(2000-j*2);
//for (int i = 0; i <= 200; i++) {}
}
Anyone got anaolgWrite working with any of the on board LED's?