Follow+Star Public Account Number, don’t miss out on exciting content
Compilation | strongerHuang
Public Account | Embedded Column
Getting to Know Arduino
1. What is a Microcontroller?
A working computer consists of the following components: Central Processing Unit (CPU for computation and control), Random Access Memory (RAM for data storage), Read-Only Memory (ROM for program storage), and Input/Output devices (I/O such as serial and parallel ports). In personal computers (PCs), these components are divided into several chips installed on a printed circuit board called the motherboard. In a microcontroller, all these components are integrated into a single integrated circuit chip, hence the name microcontroller (single-chip). Some microcontrollers also integrate additional components such as Analog/Digital conversion (A/D) and Digital/Analog conversion (D/A).
2. What is the Use of Microcontrollers?
The saying goes, why use a sledgehammer to crack a nut? Not every situation requires high performance. Imagine a voice-controlled light using an Intel i7 processor; its cost-performance ratio would be astronomical. The key to application is whether it is sufficient and whether it has a good performance-to-price ratio, which is where microcontrollers fill the gap.
3. What is Arduino?
From the perspective of microcontrollers, what is Arduino?
Arduino is a convenient, flexible, and easy-to-use open-source electronic prototyping platform, including hardware (various models of Arduino boards) and software (Arduino IDE). It is suitable for artists, designers, hobbyists, and anyone who wants to tinker.
The features are simple shapes that can interact with people, and even a ten-year-old child can use it to create what they want. Arduino can sense the environment through various sensors and control lights, motors, and other devices to feedback and affect the environment.
The microcontroller on the board can be programmed using Arduino’s programming language, compiled into binary files, and uploaded to the microcontroller. Projects based on Arduino can include just Arduino or a combination of Arduino and other software running on a PC, communicating with each other (such as Flash, Processing, MaxMSP) to achieve functionality.
Types of Arduino

To distinguish so many boards and select the right Arduino, mainly consider the following three aspects: performance, features, and size.
First, look at performance, which includes processor memory, clock frequency, and bit width. The hardware processing capability usually depends entirely on the chip on the board, which also limits the software that can run.
Next, consider features, which include everything on the board except the microprocessor, such as input/output pins, integrated components (buttons, LEDs, motor drivers, etc.), and the types and numbers of available interfaces (USB, Ethernet, etc.).
Finally, consider size. Due to the nature of different projects, the volume and weight allocated for the electronic components can vary significantly. For example, if you want to make a tracker for a dog, using a Mega with a battery pack and expansion board would result in at least a size of 10*5*5cm and a weight of 200g. Is this a tracker or a sandbag? This is why there are so many different Arduino models.
Having said so much, let’s take a look at some mainstream Arduino boards.
1. Arduino Uno
Processor: ATmega328 (8-bit CPU, 16MHz clock frequency, 2KB SRAM, 32KB flash)
Features: 14 digital I/O ports, 6 analog input ports, replaceable processor design
Size: 75 x 55mm
Price: $30
2. Arduino Leonardo
Processor: ATmega32u4 (8-bit CPU, 16MHz clock frequency, 2.5KB SRAM, 32KB flash)
Features: 20 digital I/O ports, 12 of which can be used as analog ports, native USB support
Size: 75 x 55mm
Price: $25
3. Arduino Due
Processor: Atmel SAM3X8E ARM Cortex-M3 (32-bit CPU, 84MHz clock frequency, 96KB SRAM, 512KB flash)
Features: 54 digital I/O ports, 12 analog input ports, 2 analog output ports, native USB support
Size: 100 x 55mm
Price: $50
4. Arduino Micro
Processor: ATmega32u4 (8-bit CPU, 16MHz clock frequency, 2.5KB SRAM, 32KB flash)
Features: 20 digital I/O ports, 12 of which can be used as analog ports, native USB support
Size: 50 x 18 mm
Price: $27
5. LilyPad Arduino
Processor: ATmega328 (8-bit CPU, 16MHz clock frequency, 2KB SRAM, 32KB flash)
Features: 14 digital I/O ports, 6 analog input ports
Size: 50mm diameter round
Price: $22
Installing Arduino Compiler Environment
How to Use Arduino IDE
Now, let’s assume we are using the Arduino UNO model (recommended for beginners due to its stability) and have set up the Arduino development environment and installed the USB driver as per the above steps.
1. Connect the Arduino Control Board to the Computer
Plug one end of the USB cable into the Arduino control board and the other end into the USB port of the computer. (Note: When working independently, the Arduino control board can be powered either by USB or by a power bank or adapter.)
Connect the Arduino control board to the computer
Open Arduino IDE, and the editing interface of Arduino IDE will appear
2. Get to Know Arduino IDE
Let’s briefly get to know this Arduino compiler, as we will be working with it often.
Arduino IDE is the software editing environment for Arduino products. Simply put, it is where you write code and download code.
Any Arduino product needs to have code downloaded to function.
The hardware circuit we set up assists the code in completing tasks; both are indispensable. It’s like how a person controls their body through their brain. If the code is the brain, the hardware is the body, and the body’s activities depend on the brain, so the hardware implementation depends on the code.
The basic functional areas of Arduino IDE have been marked above (I used an old image for convenience, but it has the same layout as the new version). Most of the white area in the image is the code editing area, where you input code. Note that when entering code, you should switch to English input mode. The black area below is the message prompt area, which will display whether the compilation or download was successful.
3. Download a Blink Program
Download the simplest code, which will help us familiarize ourselves with how to download programs and test the board’s functionality.
The LED marked L on the UNO board will blink with this test code.
4. Open Blink
Plug in the USB cable, open Arduino IDE, and find the “Blink” code.
File > Examples > 01.Basics > Blink
5. Verify the Program
Usually, after writing a piece of code, we need to verify it to check for errors. Click “Verify”.
After verification (compilation) is complete, you will see the corresponding prompt.
Since this is sample code, there should be no errors during verification. However, in the future, when writing code, you will need to verify it before downloading it to Arduino.
Before downloading the program, we also need to tell Arduino IDE which board we are using and which serial port corresponds to it.
6. Set the Board Type
Arduino includes various versions of controllers, among which the most common are the Uno, Leonardo, and Mega series controllers (the most comprehensive selection guide).
In the board section, you need to select the board type according to the firmware type of the main control hardware you have chosen. (In this example, we are using a controller with Uno as its bootloader) Tools > Board > Arduino Uno
7. Set the Serial Port
Tools > Serial Port > xx, where xx must match what you see in your computer’s device manager.
8. Download the Program
As shown, click “Upload” at the end. (Uploading here is the same as downloading previously.)
Upload complete!
If everything goes well, we should be able to see the program running visually on the board:
The LED on pin 13 of the Arduino Uno board is blinking.
Alright, this is the most basic operation of the IDE; I hope this article helps you.
Click “Read Original” for more sharing.