'LED_BUILTIN' was not declared

  • Arduino IDE: v1.8.16
  • Board Package: Seeed XIAO RP2040 v1.9.3

I referred to the XIAO RP2040 Wiki and tried to get the Examples > 01.Basics > Blink working.
But, I get the following error when compiling.

Wiki: https://wiki.seeedstudio.com/XIAO-RP2040-with-Arduino/

"C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\pqt-gcc\\1.3.1-a-7855b0c/bin/arm-none-eabi-g++" -c -Werror=return-type "-IC:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\rp2040\\1.9.3/tools/libpico" -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSB_VID=0x2e8a -DUSB_PID=0x000a "-DUSB_MANUFACTURER=\"Raspberry Pi\"" "-DUSB_PRODUCT=\"Pico\"" -Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions "-iprefixC:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\rp2040\\1.9.3/" "@C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\rp2040\\1.9.3/lib/platform_inc.txt" -fno-rtti -std=gnu++17 -g -DSERIALUSB_PID=0x000a -DF_CPU=125000000L -DARDUINO=10816 -DARDUINO_RASPBERRY_PI_PICO "-DBOARD_NAME=\"RASPBERRY_PI_PICO\"" -DARDUINO_ARCH_RP2040 "-IC:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\rp2040\\1.9.3\\cores\\rp2040" "-IC:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\rp2040\\1.9.3\\variants\\rpipico" "C:\\Users\\user\\AppData\\Local\\Temp\\arduino_build_426700\\sketch\\XIAORP2040_Blink.ino.cpp" -o "C:\\Users\\user\\AppData\\Local\\Temp\\arduino_build_426700\\sketch\\XIAORP2040_Blink.ino.cpp.o"
C:\Users\user\Documents\Arduino\XIAORP2040_Blink\XIAORP2040_Blink.ino: In function 'void setup()':
XIAORP2040_Blink:32:11: error: 'LED_BUILTIN' was not declared in this scope
   32 |   pinMode(LED_BUILTIN, OUTPUT);
      |           ^~~~~~~~~~~
C:\Users\user\Documents\Arduino\XIAORP2040_Blink\XIAORP2040_Blink.ino: In function 'void loop()':
XIAORP2040_Blink:37:16: error: 'LED_BUILTIN' was not declared in this scope
   37 |   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      |                ^~~~~~~~~~~
exit status 1
'LED_BUILTIN' was not declared in this scope

Looking at variants/rpipico/pins_arduino.h on the board package, it seems that LED_BUILTIN is not defined.


Hello, in this example you need to change LED_BUILTIN to the pin number you need. As we all know, the LED pins of different boards may be different, and it is impossible for us to apply this pin to all boards, so we leave the power of modification to the user.

Hi Citric,

Thank you for your reply.
I think it is preferable to define LED_BUILTIN in BSP, but how about it?

See. https://www.arduino.cc/reference/en/language/variables/constants/constants/

For example, on my arduino board, the pin number that the LED is connected to is 4, so I will define ledPin as 4, and then I can use ledPin to complete the high and low level settings during the flashing of the light.

int ledPin = 4;
void setup() {
pinMode(ledPin, OUTPUT);
void loop() {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);