How to upload code to an Arduino Uno from the command line

I recently bought an Arduino Uno and I wanted to be able to edit code in Vim and upload it directly from the command line.

  • Download and install the Arduino software.
  • Get this makefile and put it somewhere accessible to your project.
  • Create a Makefile in your project directory that looks something like this:

Now you can run make to compile or just make upload to compile and upload in one shot.