A computer program is a set of instructions written in a binary code and loaded into the memory of a computer. Under the direction of the computer’s clock, it steps through the instructions and executes them one at a time. This is true for large complex computers and small microcontrollers alike.
Most computers have a primary computer program called the “operating system” that provides an environment and set of services to assist user-level programs when they run. For example, most PCs use Microsoft Windows, Apple computers use MAC OS, and many smart phones use Android. These operating systems provide a traffic cop that allows multiple programs to run at the same time without crashing one another, a set of device drivers and libraries that make user programs more portable from one set of computer hardware to another, a file system that allows programs to make use of RAM and hard drive memory, and security controls that prevent users and programs from doing things they shouldn’t.
Operating systems are often very large and complex. (For example, Windows 10 fills 10 GB of disc space and needs at least 1 GB of RAM to run.) So beginning with initial power-on of the computer, how does the operating system get loaded and started? Just about every computer has a very small and simple piece of software called a boot loader that accomplishes this. “Boot” comes from the old phrase “to pull oneself up by one’s bootstraps.” The common computer phrase “to reboot” means to clear out everything but the boot loader and have it reload the operating system. The boot loader is very seldom changed and is often provided by a special ROM (read-only memory) chip in the computer’s hardware. When the computer’s CPU is powered on or reset, it goes to the ROM and executes the boot loader.
Because the Arduino microcontroller is so small, there is no room for a large and complex operating system. So what it does have is a special boot loader, less than 2000 bytes in size, that resides in a special location within the 32 Kb of program memory on the chip. This boot loader allows just one user program to run, and provides the ability to load that program from the USB interface. (Actually, it loads via a serial interface that is connected to USB through a special interface chip on the Arduino board.)
When the Arduino is powered on or reset, the boot loader checks to see if a new user program is available at the USB interface. If so, it loads and executes it. If there is no new program available, it transfers control to the user program already loaded. Most Arduino boards have the boot loader pre-installed and also a simple user program called “blink” that causes the LED on pin 13 to blink on and off with a 2 second cycle.
User programs for the Arduino are created in a separate program development environment that provides the ability to edit the program text, compile the program together with any needed library routines into ATmega machine language, and download the compiled program to the Arduino board via USB. The two most popular program development environments for Arduino are the Arduino IDE and Codebender. The Arduino IDE runs on a PC, MAC, or Linux personal computer. Codebender runs on an internet server and is accessed through a browser interface. For more information about Arduino program development, see the separate blog post here or consult the huge number of internet resources on the subject.