Getting Started with Arduino UNO: A Comprehensive Guide

Getting Started with Arduino UNO: A Comprehensive Guide

The Arduino Uno was released on September 25, 2011, at the New York Maker Faire. The latest official version is the Rev3, known as the Arduino Uno R3. All experiments in this book are based on this version. The Arduino Uno is based on the ATMEL AVR microcontroller ATmega328p, where the letter ‘p’ indicates low-power picoPower technology. The microcontroller on the Arduino Uno board is installed in a standard 28-pin IC socket, which allows the chip to be removed and used in other circuits once the project is completed. A new ATmega328p microcontroller can then be used to replace the chip on the Uno board, provided that the new microcontroller has been pre-programmed with the Arduino bootloader. You can purchase an ATmega328p with the bootloader already written, or you can use another Arduino Uno board to flash it yourself using the IDE. There is also a version of the Arduino Uno that uses surface-mount technology, called the Arduino Uno SMD, which additionally provides A6 and A7 interfaces.

The Arduino Uno R3 development board is shown in Figure 1-1. Since the hardware and software of Arduino are open source, all resources related to Arduino can be found online, allowing for a wide availability of Arduino Uno R3 clone boards. If desired, you can also create one yourself using the official schematics and PCB layouts.

Getting Started with Arduino UNO: A Comprehensive Guide

Figure 1-1 Arduino Uno R3

1. ATmega328p

The brain of the Arduino Uno is the Atmel AVR microcontroller ATmega328p, which is a black rectangular plastic block with a row of pins on each side. In the SMD version, the processor is directly soldered onto the PCB as a black square. It is essentially a single-chip computer, encapsulating a central processing unit (CPU), program memory (Flash), data memory (RAM), clock circuits, and peripherals.

The processor originally used in Arduino was the ATmega8, but the ATmega328 has larger memory, more internal peripherals, and lower power consumption. The ATmega328 can operate over a wide supply voltage range, from 1.8 V to 5.5 V, making it suitable for battery-powered applications. At the lowest supply voltage, the ATmega328 can only operate at a clock frequency of 4 MHz; when the supply voltage is increased to 2.7 V, the clock frequency can rise to 10 MHz; to operate at the maximum 20 MHz clock frequency, the chip requires at least 4.5 V of supply voltage.

The Arduino Uno development board supplies 5.0 V to the ATmega328 chip, which theoretically allows operation at any clock frequency below 20 MHz, but the original ATmega8 could only operate at a maximum of 16 MHz. To ensure compatibility, all subsequent Arduino models continue to use a clock frequency of 16 MHz.

Key features of the ATmega328p include:

  • High-performance, low-power 8-bit RISC microprocessor

  • 32K bytes of program memory, 10,000 write cycles

  • 1K bytes of EEPROM, 100,000 write cycles

  • 2K bytes of on-chip SRAM

  • 14 digital I/O pins (6 support PWM output)

  • 6 analog input pins (10-bit ADC)

  • 2 8-bit timers/counters

  • 1 16-bit timer/counter

  • 6 sleep modes

  • Operating voltage: 1.8 – 5.5V

  • Operating temperature range: -40℃ to 85℃

2. Power Supply

There are several ways to power the Arduino Uno board. The first method is to connect it to a computer via a USB cable, which can provide a maximum current of 500 mA to the Arduino Uno. This is sufficient to drive LEDs or low-power sensors, but not enough for high current loads like motors or solenoids. This book recommends this power supply method, as the Arduino Uno circuit board has a self-resetting fuse to protect the computer port from damage due to short circuits during experiments.

The second method is to power the Arduino Uno board through the barrel jack, which can accept an input voltage of 7-12 V. The onboard voltage regulator will then convert this voltage to 5V. However, be careful with the polarity of the barrel jack; the center pin is positive, and the outer sleeve is ground. Connecting a power supply with reversed polarity will damage the protection diode on the Arduino Uno board.

The third method is to power the Arduino Uno board through the VIN and GND pins on the expansion socket. The center pin of the barrel jack is connected to the Vin pin on this expansion socket, which means this method is equivalent to powering through the barrel jack, so the input voltage must also be 7-12 V to ensure the onboard voltage regulator functions correctly.

Finally, there is a method to power the Arduino Uno board through the 5 V and GND pins on the expansion socket, but this bypasses the onboard voltage regulator, so the 5V input must be stable. Large voltage fluctuations can permanently damage several components, including the processor, so this method is not recommended.

The current Arduino Uno board has a very good design that allows multiple power sources to be connected simultaneously. An intelligent power switching circuit will select the highest available voltage source and connect it to the voltage regulator.

The Arduino Uno board also has a 3.3 V voltage regulator that can provide 3.3V output for peripherals through the expansion socket, but the maximum output current must not exceed 50 mA.

3. Digital I/O Pins

The Arduino Uno board provides 14 digital I/O pins through the expansion socket, numbered 0 to 13, where pins 3, 5, 6, 9, 10, and 11 support PWM output and can output 8-bit PWM waves using the analogWrite() function in Arduino. Each pin must be explicitly set as either input or output mode using the pinMode() function before use. For example, the following statements set pin 12 as input and pin 13 as output:

pinMode(12, INPUT); // Set pin 12 as an input pin

pinMode(13, OUTPUT); // Set pin 13 as an output pin

In Arduino, a high level is represented by 1 or HIGH, and a low level is represented by 0 or LOW. When used as an output, if the output is high, the output voltage is close to 5V; however, this is the ideal condition without load. As soon as a load is connected, the output voltage will drop, and the larger the output current, the more significant the voltage drop. If the output is low, the output voltage is close to 0V, and when load current flows into the port, the output voltage will rise slightly, so I/O ports have a certain load capacity. It is recommended that the current for each I/O port should not exceed 20mA, and the maximum should not exceed 40mA. The total current for all I/O ports should not exceed 200mA, especially for beginners to note this point.

When used as input ports, to ensure correct logic, the input high level should be as close to 5V as possible, and the input low level should be as close to 0V as possible.

It is essential for beginners to avoid using pins 0 and 1 on the expansion socket of the Arduino Uno, as these correspond to the serial communication ports used for communication between the Arduino Uno board and the computer. Experienced programmers can use the serial port corresponding to pins 0 and 1 for communication with other devices in their final projects or as general digital I/O ports, but it is not recommended for beginners.

4. Analog Input Pins

The Arduino Uno board provides 6 analog input pins through the expansion socket, numbered A0-A5. The ATmega328 has a built-in 10-bit analog-to-digital converter (ADC) that can convert the analog input signals on the pins into 10-bit digital signals. By default, the analog input voltage range is 0-5V, and the AREF pin and analogReference() function can be used to set the analog input voltage range.

In the Arduino IDE, the A0-A5 pins do not need initialization when used as analog input pins; you can directly read the corresponding port values using the analogRead() function. For example:

analogRead(A0); // Read the analog value from A0 and convert it to a 10-bit digital value

The analog input pins A0-A5 can also be used as regular digital I/O pins, and before use, the pinMode() function must be used to specify the port as input or output mode.

5. Reset

There is a reset button next to the USB interface on the Arduino Uno board. When pressed, the microcontroller performs a reset operation, which is equivalent to re-powering the board.

The reset pin (RESET) on the expansion socket will also reset the Arduino when connected to a low level. Pressing the reset button effectively connects the reset pin to a low level, causing the Arduino to reset.

6. Indicator Lights

The Arduino UNO board has four LED indicator lights, which serve the following purposes:

  • Power indicator (ON): Lights up when the Arduino board is powered on.

  • Serial transmission indicator (TX): Flashes when the Arduino transmits data to the computer.

  • Serial reception indicator (RX): Flashes when the Arduino receives data from the computer.

  • Programmable control indicator (L): This LED is connected to pin 13 of the Arduino Uno expansion socket and lights up when pin 13 is high.

Getting Started with Arduino UNO: A Comprehensive Guide

Leave a Comment

Your email address will not be published. Required fields are marked *