What you need
- ELEGOO Mega 2560 with its ATmega2560 marking checked.
- A data-capable USB-B cable and a computer with internet access for tool installation.
- VS Code with PlatformIO IDE. No breadboard, external LED or jumper wires are needed.

Use USB power and leave the headers disconnected for this first run. Mega GPIO uses 5 V; check compatibility before adding 3.3 V parts.
Setup
Install the editor and extension
Install VS Code. In Extensions, search for PlatformIO IDE by PlatformIO, install it, and let its setup finish. Already completed the Uno setup? Keep that installation; only the downloaded board project changes.
Connect the Mega
Plug the USB-B cable into the board and your computer. A power LED alone does not prove the cable carries data. If several boards are connected, disconnect the others so the upload target is clear.
Your first program
The program turns the onboard LED on and off every half-second and prints a heartbeat once per cycle.
#include <Arduino.h>
#ifndef ARDUINO_AVR_MEGA2560
#error "Select the reviewed Mega 2560 environment."
#endif
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
Serial.println("Engineering Club: Mega heartbeat");
}
platformio.ini
[env:mega]
platform = atmelavr@5.3.0
board = megaatmega2560
framework = arduino
monitor_speed = 9600
Download and open the project
Download the complete project, extract the ZIP, then use File → Open Folder… in VS Code. Open the extracted folder containing both
platformio.iniandsrc—not justmain.cpp. Keep the supplied configuration:board = megaatmega2560selects the Mega instead of the Uno.Build
Open PlatformIO's Project Tasks → mega → General → Build. Wait for dependency installation on the first build, then look for SUCCESS in the terminal. If you prefer commands, open a PlatformIO terminal in the project folder and run:
pio run -e megaUpload
Close any Serial Monitor using the board. Choose Project Tasks → mega → General → Upload, or run the command below. Wait for SUCCESS before disconnecting. Upload replaces the program already on the board.
pio run -e mega -t upload
Verify it works
The onboard LED should stay on for about half a second, then off for half a second. Open Project Tasks → mega → General → Monitor, or run the command below. At 9600 baud, expect the line shown to repeat about once a second. This monitor speed is different from the bootloader's upload speed. Press Ctrl+C to close a terminal monitor before another upload.
pio device monitor -b 9600Engineering Club: Mega heartbeatTroubleshooting
- Board or upload port not detected
Try a known data cable and another USB port. Check the device that appears when you connect the Mega. Install a USB driver only after identifying its actual USB bridge; do not guess a COM number.
- Upload port is busy
Close all serial monitors and other apps using the board, then upload again. If multiple ports remain, select the one that disappears when this board is unplugged.
- Wrong target or upload fails
Check
board = megaatmega2560in the supplied configuration and select themegatask. If the board still will not respond, check its actual bootloader and USB interface before changing upload settings.- Serial Monitor is blank or garbled
Set the monitor to 9600 baud and select this board's port. Press RESET once; a successful upload should resume the repeating heartbeat.