Skip to content

Arduino IDE ​

Experiment 3 onward runs on the Arduino Mega 2560. The Arduino IDE runs on Windows, macOS and Linux, and the lab PCs already have it.

1. Install the Arduino IDE ​

  1. Download Arduino IDE 2 from arduino.cc/en/software and install it with the defaults. On Windows, accept the USB driver prompts.
  2. Plug the Mega in with its USB cable. The green ON LED lights.
  3. Pick the board and port from the drop-down at the top of the window, or from the Tools menu:
    • Tools → Board → Arduino AVR Boards → Arduino Mega or Mega 2560
    • Tools → Port → the port labelled Arduino Mega or Mega 2560 (COMx on Windows, /dev/cu.usbmodem… on macOS)
Choosing the board and port

2. Upload a sketch ​

ActionButtonShortcut
Verify (compile only)✓Ctrl+R
Upload to the board→Ctrl+U
Serial Monitormagnifier, top rightCtrl+Shift+M

File → New Sketch opens an empty sketch with setup() and loop(). Paste your code over it, then Upload. The output pane ends with Done uploading and the board starts running the new sketch at once. It keeps running it, even after a power cycle, until you upload something else.

Serial Monitor shows what the sketch sends with Serial.print(). Set the baud rate in its drop-down to the same number as Serial.begin() in your code, normally 9600.

Upload output and the Serial Monitor

3. Install a library ​

Some experiments use libraries that do not come with the IDE. Open the Library Manager (the books icon on the left, or Sketch → Include Library → Manage Libraries…), search for the name the experiment gives, and click Install.

Troubleshooting ​

SymptomCause and fix
Upload fails with avrdude: stk500v2_getsync(): timeout communicating with programmerWrong board or port. Re-select both in Tools. Unplug anything wired to pins 0 and 1, which share the USB serial line.
No port appearsTry another cable, since some are power-only. On Windows, check Device Manager for an unknown device and reinstall the IDE's drivers.
Serial Monitor shows garbageThe baud rate in the monitor does not match Serial.begin().
fatal error: Keypad.h: No such file or directoryThe library is not installed. See Install a library.