Follow+Star Public Account Number, don’t miss wonderful content
Editing | strongerHuang
WeChat Public Account | Embedded Column
Embedded Column
1
1. What is a microcontroller?
A working computer consists of the following parts: 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 ports, parallel output ports, etc.). In a personal computer (PC), these parts are divided into several chips installed on a printed circuit board called the motherboard. In a microcontroller, all these parts are integrated into a single integrated circuit chip, hence the name microcontroller (single-chip machine). Some microcontrollers also integrate other components such as Analog/Digital conversion (A/D) and Digital/Analog conversion (D/A).
2. What is the use of a microcontroller?
As 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-effectiveness would be astronomical. The key to application is whether it is sufficient and whether it has a good performance-to-price ratio, so microcontrollers fill this gap well.
So, what is Arduino?
Arduino is a convenient, flexible, and easy-to-use open-source electronic prototyping platform that includes hardware (various models of Arduino boards) and software (Arduino IDE). It is suitable for artists, designers, enthusiasts, and anyone who wants to tinker. Its features include simple shapes, the ability to interact with people, and even ten-year-olds can use it to create what they want. Arduino can sense the environment through various sensors and can control lights, motors, and other devices to respond to and affect the environment. The microcontroller on the board can be programmed using the Arduino programming language, compiled into binary files, and uploaded to the microcontroller. Projects based on Arduino can include only Arduino or can include Arduino and other software running on a PC, which communicate with each other (e.g., Flash, Processing, MaxMSP) to achieve functionality.
Embedded Column
2

To distinguish between so many boards and choose the right Arduino, mainly look at the following three aspects: performance, features, and size.
First, look at performance. This includes processor memory, clock frequency, and bit width. The hardware processing capability usually depends entirely on the chip of the board, which also limits the software that can run.
Next, look at features. This includes everything on the board besides 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, look at size. Due to different project requirements, the volume and weight allocated for electronic components can vary greatly. For example, to make a tracker for a dog, if you use a Mega board and a battery box with an expansion board, it would need to be at least 10*5*5cm in size and weigh 200g. Is this a tracker or a sandbag? This is why Arduino has so many siblings.
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 memory)
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 memory)
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 memory)
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 memory)
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 memory)
Features: 14 digital I/O ports, 6 analog input ports
Size: 50mm diameter round
Price: $22
Embedded Column
3
Embedded Column
4
Now, let’s assume we are using the Arduino UNO control board (it is recommended for beginners due to its stability) and that we have already 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 from USB or from a power bank or power adapter.)
Connecting the Arduino control board to the computer
Open the Arduino IDE, and the editing interface of the Arduino IDE will appear.
2. Understanding Arduino IDE
Let’s briefly get to know this Arduino compiler, as we will often interact with it in the future.
Arduino IDE is the software editing environment for Arduino products. Simply put, it is where you write and download code.
Any Arduino product needs to download code to operate.
The hardware circuit we build is auxiliary to the code, and both are indispensable. It’s like a person controlling their limbs through their brain. If the code is the brain, the peripheral hardware is the limbs; the activity of the limbs depends on the brain, so hardware implementation depends on the code.
The basic functional areas of the Arduino IDE have been marked in the image above (I used an old image for convenience, but the layout is the same 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 need to 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 can help us familiarize ourselves with how to download programs and also test whether the board is functioning properly.
The LED marked L on the UNO board is the one we will test. This test code will make this LED blink.
4. Open Blink
Plug in the USB cable, open the 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 if there are any errors. Click “Verify.”
After verification (compilation) is complete, you can see the corresponding prompt.
Since this is sample code, there will be no errors during verification, but in the future, after entering code, you will need to verify it before downloading it to the Arduino.
Before downloading the program, we also need to tell the Arduino IDE which board we are using and which corresponding serial port.
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 hardware you choose. (In this example, the controller with the Uno bootloader is selected.) 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, finally, click “Upload.” (Here, upload and download are actually the same thing.)
Upload complete!
If everything goes well, we will be able to visually see the program running on the board:
The LED on pin 13 of the Arduino Uno board is blinking.
Well, that’s the most basic operation of the IDE.
Disclaimer:This article’s material comes from the internet, and the copyright belongs to the original author. If there are any copyright issues, please contact me for deletion.
Reply with 『Microcontroller』『MCU』 to read more related articles.
Click “Read the Original” to see more shares, welcome to share, collect, like, and check it out.