[BUG] VS Code Arduino Mega Serial Port

Hi guys, recently I found out that when you are coding Arduino mega to use its secondary serial ports, it is always “undefined” at Serial1 / Serial2 / Serial3. However the build and verify doesn’t have any issue

The way to resolve this, is to locate this file

.vscode/arduino.json

After locating the file, add a “buildPreferences” at the end of the json

    "buildPreferences": [
        ["build.extra_flags", "-D__AVR_ATmega2560__"]
    ]

Leave a Comment