I picked up my Arduino Nano 33 BLE Sense for the first time in a while and ran the classic "Blink" sketch to make sure it was alright. After slight usage, I wanted to play with the onboard LEDs. When I run the following code, the onboard LED does not turn on:
#define RED 22
void setup() {
pinMode(RED, OUTPUT);
}
void loop() {
digitalWrite(RED, HIGH);
}
However, when I run the following code, the onboard LED does turn on and stays on - it doesn't blink:
#define RED 22
void setup() {
pinMode(RED, OUTPUT);
}
void loop() {
digitalWrite(RED, LOW);
delay(1000);
digitalWrite(RED, HIGH);
}
What's happening? Is my Nano busted?
LOW
signal to the appropriate LED pin. The fact that it doesn't blink in the second sketch is because you turn the LED on (LOW
), wait one second, turn it off again (HIGH
) but it will immediately (within a few microseconds) turn on again in the nextloop()
iteration. If you want it to stay on for longer, you should place adelay()
after it's turned off (digitalWrite(RED,HIGH);
).