Until a few weeks ago, I didn’t know exactly what was the difference between Arduino and its “core” Atmega328.
I read here and there that the Atmega328 can work in stand-alone, with or without the Arduino bootloader, and even in its minimal configuration, without any external components.
I was so confused about what exactely is Arduino and the ATmega328 “without Arduino”, as they have not much information on the Internet.
Eventually, with a lot of patience, “munching” here and some information on various blogs, reading magazines and books, and doing field trials, I finally came on the bulb (or LED) in my head and all appeared more clearly.
So I decided to publish this post where I explain briefly and simpy (and probably not in a totally professional way – I would ask apologize if there are any inaccuracies) what is Arduino and what sets it apart from the Atmega328 (which is included in last generation Arduino boards).
If I had to define the Arduino project, i can say that Arduino is an open source hardware & software platform which allows you to use more quickly and easily the potential offered by the microcontroller ATmega328.
The hardware part, is typically represented by the boards listed on the official website, with lots of open schemes that allow us to realize by ourself the various Arduino boards or modify and customize them to our liking. The software part is instead represented by the often quoted bootloader, libraries and by the IDE interface that allows you to program and debug our Arduino board.
But what are the differences between Arduino and its ATmega328 microcontroller and what are the advantages in microcontroller programming?
From the perspective of hardware, the Arduino board (for example Arduino UNO) is ready for use: it has everything we need to program the microcontroller just plugging the board into the USB port of the PC: it has on board an internal power connector, a USB port, a processor that acts as a USB / Serial converter, a power LED, a status LED connected to pin 13, two LEDs indicating TX / RX, female strip header for connection of I / O ports and of course our ATmega328 microcontroller with Arduino bootloader already loaded.
In this way, opening the IDE and selecting the serial port of the PC we can load our sketch with a button and in a few seconds (typically 2-3). The upload is done via the serial port emulated by USB, which is connected to the TX and RX pin of the Atmega (pins respectively 3 and 2).
From the point of view of the software, the bootloader preloaded on Atmega (whether that is mounted on an Arduino board or just on a breadboard), is what allows serial communication with our PC. Without the bootloader to load the sketch (our “programs”), we would need an AVR programmer, more expensive, a bit ‘more cumbersome to use and slower to load the sketch. The bootloader is therefore a program, a firmware might say, whose job is basically to upload our sketch compiled into the flash memory of the microcontroller via serial communication, making sure that this program is not going to overwrite the memory area where bootloader resides. So when we upload a sketch we’re going to write in a zone of free memory and the bootloader is not affected and remain intact.
The main advantage compared to Atmega without bootloader, as we have seen, is that it can be uploaded via a simple serial communication, and at a faster rate than that which we directly loading the sketch using AVR programmer.
In addition to the bootloader, we have included libraries in the Arduino IDE. These libraries add many functions and constants that make it possible to greatly simplify the code we are going to write making it much more usable than the standard microcontroller. All this is managed through the IDE, which is the Arduino interface in which we write the sketchs, we upload and debug.
That said (hoping not to have bored and to be able explain without creating further confusion) in the next post we will see how to build a stand-alone Arduino, and how to program the ATmega328 without a bootloader, solution that sometimes could be advantageous.