
What is Arduino?
Before we start, let me share a piece of knowledge: Arduino is an Italian brand. Arduino is an open-source electronic prototyping platform that has flexible and easy-to-use hardware (various development boards) and software (Arduino IDE, which is the programming environment). Gianyou Electronics Technology Co., Ltd. is one of the few authorized companies for Arduino in China, insisting on genuine products. We combat and resist various forms of piracy, modified versions, and compatible versions, and we advise consumers not to purchase them to avoid unnecessary troubles. Arduino is designed for designers, artisans, hobbyists, and anyone interested in developing interactive devices or interactive development environments.
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 a binary file, and burned into the microcontroller. Programming for Arduino is done using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Projects based on Arduino can consist of only Arduino or include Arduino and other software running on a PC that communicate with each other (such as Flash, Processing, MaxMSP).
How to learn Arduino?
Arduino has seen rapid international development in recent years, and tutorials are abundant. If your English is excellent, I recommend learning from the official Arduino website www.arduino.cc. If your English is not good, or if you prefer to read tutorials in Chinese, you can read Chinese tutorials on forums (link: http://www.arduino.cn/thread-1066-1-1.html).
Understanding Arduino UNO
Arduino UNO is the best choice for beginners. At the time of writing this book, its latest version is UNO R3, and most of the content in this book is based on Arduino UNO R3. The detailed composition of Arduino UNO is shown in the image below.
1. Power Supply
Arduino UNO has three power supply methods:
● Powered via USB interface, voltage is 5V;
● Powered via DC power input interface, voltage requirement is 7-12V;
● Powered via the power interface at 5V or VIN port, the supply at the 5V port must be 5V, while the supply at the VIN port must be 7-12V.
2. Indicator Lights (LED)
Arduino UNO has 4 LED indicator lights, which serve the following functions:
● ON, power indicator light. The ON light will illuminate when Arduino is powered.
● TX, serial transmission indicator light. The TX light will illuminate when using USB to connect to a computer and Arduino transmits data to the computer.
● RX, serial reception indicator light. The RX light will illuminate when using USB to connect to a computer and Arduino receives data from the computer.
● L, programmable control indicator light. This LED is connected to pin 13 of Arduino through a special circuit. When pin 13 is high or in a high-impedance state, this LED will illuminate; when it is low, it will not illuminate. Therefore, this LED can be controlled to turn on or off through programs or external input signals.
3. Reset Button
Pressing this button will restart the Arduino and run the program from the beginning.
4. Memory
The memory of Arduino refers to the storage space integrated into its main control chip. The storage space of Arduino can also be expanded by using peripheral chips. The storage space of Arduino UNO is divided into three types:
● Flash, with a capacity of 32KB. Of this, 0.5KB is used as the BOOT area to store the boot program, enabling the program to be downloaded via the serial port; the remaining 31.5KB is user storage space. Compared to today’s hard drives, which can be several hundred GB, 32KB may seem small, but it is already sufficient for large programs on microcontrollers.
● SRAM, with a capacity of 2KB. SRAM is equivalent to the memory of a computer, which needs to allocate a certain storage space when the CPU is performing calculations. Data in SRAM will be lost when Arduino is powered off or reset.
● EEPROM, with a capacity of 1KB. EEPROM stands for Electrically Erasable Programmable Read-Only Memory, which is a type of read-only memory that can be modified by the user. Its characteristic is that data in EEPROM will not be lost when Arduino is powered off or reset.
5. Input/Output Ports
As shown in the image, Arduino UNO has 14 digital input/output ports and 6 analog input ports. Some of these ports have special functions, as follows:
● UART communication, for pins 0 (RX) and 1 (TX), used for receiving and sending serial data. These two pins communicate with the computer via serial communication through the ATmega16U2.
● External interrupt, for pins 2 and 3, can accept external interrupt signals.
● PWM output, for pins 3, 5, 6, 9, 10, and 11, can be used to output PWM waves.
● SPI communication, for pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK), can be used for SPI communication.
● TWI communication, for pins A4 (SDA), A5 (SCL) and TWI interface, can be used for TWI communication, compatible with IIC communication.
● AREF, the input port for analog input reference voltage.
● Reset, the reset port. Connecting it to low level will reset the Arduino. When the reset button is pressed, this port will connect to low level, thereby resetting the Arduino.

