Getting Started with Arduino: Setting Up Your Environment

Getting Started with Arduino: Setting Up Your Environment

Getting Started with Arduino: Setting Up Your Environment

Arduino is a microcontroller model that is very popular among makers. Due to its convenient operation and a wealth of peripheral resources, it is very suitable for beginners to cultivate their interest in microcontroller control. You can easily unleash your imagination to create various interesting DIY projects. Therefore, it can be said that if you want to quickly enter the world of microcontroller control, Arduino is definitely your first choice.

Getting Started with Arduino: Setting Up Your Environment

1.1.1 Materials Required

Setting up the microcontroller development environment requires consideration of two aspects: the hardware part, first, you need to purchase an Arduino board and a matching USB cable (usually provided by the seller); the second is the software part, you need to install the Arduino IDE, which is the programming software for Arduino.

Getting Started with Arduino: Setting Up Your Environment

Arduino UNO and USB cable

Getting Started with Arduino: Setting Up Your Environment

Arduino IDE

1.1.2 Choosing an Arduino Model

There are many different models of Arduino development boards, mainly to adapt to different development scenarios.

Getting Started with Arduino: Setting Up Your Environment

Comparison of Arduino Versions

How to read this table? Actually, for beginners, the main focus should be on working voltage, digital I/O, PWM, and analog input I/O. The focus on working voltage is to prevent burning the board. Remember, except for the external power supply interface, no other interface can exceed 5V (Due is 3.3V). The latter three items are mainly to prevent discovering that there are no interfaces available halfway through wiring. The interfaces of the microcontroller are generally referred to as pins (Pin), mostly connected by pin headers or sockets. The main function of the pins is to input and output voltage and current, that is, the I/O function. According to the voltage and current function, it can be divided into power pins (VCC\, VIN\, GND) and signal pins (IN\, OUT), and according to the nature of voltage and current, it can be divided into digital input, digital output, analog input, and PWM (pulse width modulation) output.

Getting Started with Arduino: Setting Up Your Environment

Socket (left) and Pin Header (right)

VCC and VIN connect to the positive terminal of the power supply, generally for power input. Additionally, a pin like +5V may be for power input or output, but all are positive. GND connects to the negative terminal of the power supply. Be careful not to confuse wiring with GND. Be sure not to reverse VCC and GND! Understanding digital (Digital) and analog (Analog) signals is actually quite simple. The former is either high level (HIGH, 1, 5V) or low level (LOW, 0, 0V), while the latter is a voltage signal that varies continuously between 0-5V. Microcontroller chips can only process digital signals, so analog signals must be converted to digital signals using ADC devices, and the analog pins of Arduino already have this function. Digital signals must be converted to analog signals using DAC devices, but unfortunately, Arduino does not have this, so we can only obtain similar analog signal output through PWM modulation.

After discussing so much about pin knowledge, still not sure how to choose? It’s actually quite simple; the commonly used models are generally UNO, NANO, MEGA2560. If you think you can only meet your requirements by using DUE, I recommend entering the study of STM32 microcontrollers.

01

UNO

Essential for beginners, possessing all basic functions of Arduino. Below is the pin definition diagram for UNO, the image is sourced from the internet, and I suggest everyone save it. I have always believed that regardless of what microcontroller, module, or chip you learn, you must understand the pin definition or I/O port definition; this is the basis for later wiring.

Getting Started with Arduino: Setting Up Your Environment

02

Nano

Nano is known for its compact size, making it suitable for creating small smart devices or wearable devices. Its pin definition is basically the same as UNO, and its functionality is similar, allowing programs to be directly ported. Considering that everyone will need to frequently refer to English Data Sheets in the future, I found an English pin definition to compare with the above UNO.

Getting Started with Arduino: Setting Up Your Environment

03

Mega 2560

The biggest feature of Mega2560 is its abundant number of pins. Notably, both UNO and NANO only have one set of serial communication pins, while Mega has four sets, which is very appealing. Therefore, when you need to use many pins or require more serial communication, Mega2560 is definitely the first choice.

Getting Started with Arduino: Setting Up Your Environment

Additionally, it is worth mentioning that Arduino Mega2560 is the control chip for many 3D printers, which means you can take this opportunity to learn about 3D printer production.

Getting Started with Arduino: Setting Up Your Environment

3D printing kit based on Mega2560

As for how to purchase, I believe everyone should have no problem. There are many options on Taobao, and you can choose a reasonably priced one. In this tutorial, it is not recommended to purchase kits. Of course, if you don’t want to search for modules one by one, you can buy a kit; it’s just a matter of price.

1.1.3 Installing IDE and Drivers

Arduino IDE is a cross-platform program written in JAVA, so you can use this IDE on Windows, Mac, and Linux operating systems.

The Arduino Chinese community has provided the latest IDE download link below. The latest version is 1.8.5. You can choose the version that matches your operating system for download and installation. The installation process is very simple, so I won’t elaborate on it here.

http://pan.baidu.com/s/1kUI1Pbh

Getting Started with Arduino: Setting Up Your Environment

After the software installation is completed, generally, you need to install the CH340 driver to connect properly with the microcontroller. The method to check if the microcontroller is connected is simple: plug the microcontroller into the computer, enter the IDE, go to the Tools menu. If the power light of the microcontroller is on, but the port in IDE is grayed out and cannot be selected, it means the microcontroller is not connected properly and you need to install the CH340 driver.

Getting Started with Arduino: Setting Up Your Environment

Port is grayed out and cannot be selected

CH340 is a USB to serial chip, so only by installing the correct driver can you connect to the microcontroller properly. I also provide the driver installation files: one is for Windows (64-bit system, compatible with XP-WIN10), and one is for Mac (OSX 10.9 and above). You can reply in the public account backend: #CH340 to obtain.

For the Windows version, find SETUP.EXE, open it, and if the uninstall button is available, click uninstall first, then click install. If it is not available, just click install directly.

Getting Started with Arduino: Setting Up Your Environment

For the Mac version, simply double-click CH34x_Install_V1.4.pkg to enter the driver installation state. To determine if the installation is complete, you can check the dev folder or go to About This Mac – System Report – Hardware to see if there is a Serial port.

Getting Started with Arduino: Setting Up Your Environment

Once the CH340 driver installation is complete, you will be able to see the selectable port in the IDE.

Getting Started with Arduino: Setting Up Your Environment

Everyone should note that each time you connect the microcontroller, you must check two things: first, whether the port is selected; every time you change the USB port you plug into the computer, the port will change. If the port is not selected, you cannot download the program to the microcontroller.

Getting Started with Arduino: Setting Up Your Environment

Second, the development board model; make sure to select the model that matches the microcontroller. We are developing with UNO, so select UNO. Once both are selected, you can start testing whether our environment setup is successful.

1.1.4 Testing if the Environment Setup is Successful

Next, we will determine if our development environment has been set up by using a built-in example program (Demo).

Getting Started with Arduino: Setting Up Your Environment

We choose Blink (flashing), a classic example akin to the Hello, World program, as our test program. There are five buttons at the top of the interface, the first is used to check if your program has errors after you finish programming, the second is used to download the program to the microcontroller, a process we often refer to as programming. The general steps are programming – verification – programming.

Getting Started with Arduino: Setting Up Your Environment

We select the second button to upload the example program to our microcontroller. When it shows that the upload is successful and you can see the LED on the microcontroller blinking every second, congratulations, your development environment is set up successfully, and you can start creating!

Getting Started with Arduino: Setting Up Your Environment
Getting Started with Arduino: Setting Up Your Environment

1.1.5 Common Errors and Solutions

In the setup process, it is not possible for everyone and every device to have a smooth experience. If errors occur, the best solution is to first search the internet for corresponding solutions. Generally speaking, due to the vast number of Arduino users, the difficulties you encounter have definitely been faced by others, and solutions may already exist. I have summarized three error prompts from IDE during my setup and my solutions.

Getting Started with Arduino: Setting Up Your Environment

Next Lecture Preview

1.2 will introduce some commonly used electronic components and modules to lay a foundation for subsequent use and development.

Getting Started with Arduino: Setting Up Your Environment

About this Tutorial

Arduino is the first microcontroller I encountered. I had always heard of the C51 microcontroller, but since the 51 is indeed quite old, Arduino, as a new open-source microcontroller system, is supported by many makers both at home and abroad, and even many teenagers have started to learn how to use this microcontroller. The downside of this microcontroller is also its advantage: it is easy to operate and learn, which means it encapsulates a lot of low-level things. If you want to further dive into microcontrollers or embedded systems, Arduino is indeed not ideal, but as an entry point, you can focus less on low-level things and more on understanding programming (algorithms), usage methods of various peripherals (components), and automatic control methods. When you feel that Arduino cannot meet your requirements, switching to the current mainstream chip ARM is also relatively easy; what you need to learn is only the ARM chip itself.

I also took some time (actually spent half a night) to start this for everyone because the next month and a half involves exam week review issues, and I personally do not have time to update. I also hope that everyone does not get too immersed in learning microcontrollers and neglect their final exam reviews, so this tutorial serves as an introduction, and the next one will likely have to wait until after the final exams. Therefore, the tutorial is mainly planned for release during the winter vacation, which can be considered a winter vacation benefit. The reason for creating this tutorial is simple: I hope to summarize what I have learned about Arduino over the past year and also pass it on to everyone, especially to those who have joined our research preparation team.

Future tutorials will contain more of my own insights and summaries. They may not always be entirely correct, and they may be more clever than the currently popular tutorials. In any case, I believe I can persist, and you can supervise me~ If there are any inaccuracies, you can leave a message below, and I will reply promptly. The content of the tutorial is mostly original, so I hope everyone can cherish my hard work, and I will continue to pass on the spirit of Arduino’s open source. I do not regret the time I have spent on this matter, including the time I have spent on this public account. Many times, when I am busy, to keep up with the content for everyone, I may need to stay up late to write, but I believe that providing something meaningful for everyone is worth doing.

Of course, the greatest encouragement for me is the number of fans and views~~~~~~~ Love you all!

Getting Started with Arduino: Setting Up Your Environment

Leave a Comment

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