Open technoblogy opened 1 year ago
This is done in initvariant(), part of variant.cpp. This function is called from main.cpp during startup.
// bootloader configures LED_BUILTIN as PWM output, deconfigure it to avoid spurious signals
pinMode(LED_BUILTIN, OUTPUT);
//pinMode(LEDB, OUTPUT);
//pinMode(LEDR, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
The led pin is defined in pins_arduino.h as :
#define PIN_LED (13u)
#define LED_BUILTIN PIN_LED
It would be better to set as INPUT.
That said the tinyusb-bootloader seems / could be using the status led. So maybe it is a good idea to document a warning to the users that D13 could be used during startup and for status Led from a sketch (like with Blink)
Thanks for your post. A couple of comments:
The standard Blink example file included with Arduino cores already includes the line:
// initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT);
The most important point is that every other Arduino-compatible board I'm aware of sets LED_BUILTIN
as an input at reset.
thanks Maybe I was not clear, but I fully agree with you.
On the Uno R4 Minima and Uno R4 WiFi, pin 13 is made an output after reset, so if you do:
and apply 5V to the pin (via a resistor for safety), you still get 0.
The usual Arduino convention is that all digital pins are inputs after reset, and to make a pin an output you have to call
pinMode(13, OUTPUT)
, for example. As far as I know no other Arduino board does this.The way it is currently working is undesirable, because you might have pin 13 connected to a voltage input; an accidental reset could then cause excessive dissipation in the output driver.
Note: Originally posted on the Early Access Program forum, but still an issue.