I tried uploading any kind of sketch (including the bare bones one), and nothing worked. Other people said this error was caused by a lack of permissions on the port, and so I did what was suggested by several others and the arduino site (for linux).
Sketch uses 3462 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {}
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyS4, } => {}
PORTS {/dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/kalin/Downloads/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/kalin/Downloads/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_767551/sketch_feb05a.ino.hex:i
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/home/kalin/Downloads/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/home/kalin/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
Using Programmer : avr109
Overriding Baud Rate : 57600
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
avrdude done. Thank you.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
From the documentation:
Open Terminal and type:
ls -l /dev/ttyACM* you will get something like:
crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0 The "0" at the end of ACM might be a different number, or multiple entries might be returned. The data we need is "dialout" (is the group owner of the file).
Now we just need to add our user to the group:
sudo usermod -a -G dialout $USER then:
sudo chmod a+rw /dev/ttyACM0 You will need to log out and log in again for this change to take effect.
However every time I launched arduino, the permissions would be cleared back to what it was before. If I ran arduino as sudo it worked, but I obviously shouldn't need to do that.