When you open the Arduino IDE, you get a screen similar to the one shown. Now what? In this tutorial we will take a short look at the essentials, so you can jump in and start programming your Arduino. For help installing the Arduino IDE, see the installation instructions on the Arduino website.
"File->New" creates a new source file with the empty setup() and loop() functions. This is the same source file you get when you start the IDE. It will compile and upload, does absolutely nothing, except occupy some Flash and look for serial events. When you compile the code, the IDE will ask you to save the file. The file will be saved in a directory having the same base name as the file. For instance, if you save the file as "test" it will be saved as "test.ino" in a directory named "test".
"File->Save" saves a file. You choose the directory and filename and the IDE saves the file. The default extension is "ino". Files will be saved in your sketchbook folder, the location of which may be changed in preferences. Files are saved in a directory having the same base name as the file, as above.
"File->Open" opens a file. You choose the directory and filename and the IDE loads the file. If the file is not in a directory named as described above, the IDE will complain that the file needs to be in a folder named the same as the file, and ask if it can create the directory and move the file. The only real choice is "OK". "Cancel" stops loading the file.
"Sketch->Verify/Compile" compiles the source. In the Arduino IDE, compiling is called "Verifying". It can also be done by clicking on the check mark in the upper lefthand corner of the IDE window.
"Sketch->Upload" uploads the binary file using the bootloader. The arrow at the upper left, next to the check mark is the upload button. The file is uploaded serially using the USB cable. If there is a problem, the upload will fail, leaving you with an error message that means absolutely nothing. Check the connections, power cycle the Arduino, then try again. You may have to reselect the serial port to use for uploading.
"Sketch->Upload using programmer" causes the IDE to use the default programmer to burn the binary file to Flash memory. This works whether there is a bootloader or not. You can also do it by holding the Shift+Ctl+U (Shift+Cmd+U on a Mac). You can also use "Shift+click on the arrow". Configure your programmer first, at "Tools->Programmer". If you don't have a programmer, get one. They are very handy, and dirt cheap on ebay.
If the bootloader gets hosed, or rather when the bootloader gets hosed, or when you change out the MCU, you will need to put a new bootloader in the Flash. "Tools->Burn Bootloader" will use the default programmer (you have a programmer, right?) which you select on the tools menu, to burn a new bootloader. After that, you can use the normal upload procedure to upload code through the bootloader.
The IDE has a built-in serial monitor, like a terminal, that can be accessed by "Tools->Serial Monitor" menu option. The serial monitor defaults to a serial speed of 9600 Baud, which is about 960 characters per second. The Arduino core code has a built-in serial library that can be used to send data back to the serial monitor. The serial monitor and the serial code on the Arduino must be the same speed. If you open the serial port with:
Then you are going to have to set the serial monitor to the same rate - 115200 Baud.
Code gets messy after you cut and paste from different sources. There is a "beautifier" in the tools menu: "Tools->Auto Format" that will fix the indentation in your code and make it look like new. A must to keep your code legible.