Setting Up the Programming Environment

Before starting programming the microcontroller, it is necessary to connect it to the computer.

Connection

Arduino Uno microcontroller is taken as a board for programming example tasks. It can be connected to a computer, using Universal Serial Bus (USB) port, using the appropriate USB cable. A microcontroller can be used together with a prototyping board or a robot. In the simplest programming tasks, it can be used as an independent device.

Power

The microcontroller has to be powered via an external power supply or USB port. The microcontroller determines the power source automatically. If external power supplies other than USB are used, GND and VIN ports should be used to connect the power supply. The manufacturer recommends the use of a voltage of 7–12 V to ensure a normal operation of the microcontroller. If the voltage is exceeded, before reaching 20 V, then the power supply circuits of the microcontroller may get overheated. If the supply voltage is lower than 7 V, then the microcontroller may function unstable, and the result will be unpredictable.

In addition to the above mentioned, the microcontroller can provide a small power supply for external circuits by connecting them according to the microcontroller pins.

Table 1: The Power Pins of Arduino UNO
Pin Description
VIN The input of a power supply when a USB port is not used, i.e., an external power supply is used
5V A regulated 5 V power supply, which can be provided via both USB and VIN
3.3V A 3.3 V supply voltage for external circuits. The maximum current that this output can provide is 50 mA. If it is exceeded, the power supply circuits of the microcontroller may be permanently damaged
GND Ground or port 0
Inputs/Outputs

Each of the 14 digital inputs/outputs (I/O) of the microcontroller can be used to send or receive signals using the pinMode(), digitalWrite() and digitalRead() commands, which will be more detailed discussed in the chapter about the basics of programming. All I/O operate in the range of 0 V to 5 V. Each of the I/O is capable of receiving or sending no more than 40 mA of current. They all have internal load resistors in the range of 20–50 kΩ.

Descriptions of other microcontroller pin and their specific use are explained below. In addition to these I/O, the microcontroller also provides other specific functions that will be described below.

Table 2: Specific I/O Pins of Arduino UNO
Pin Description
0(RX) and 1(TX) Serial I/O for serial communication. RX is used for receiving data, and TX for sending data to external devices. For data transmitting and receiving, the voltage must not exceed 5 V
2 and 3 External interrupt pins that can be used to receive an external interrupt in cases when the value is low, the value is changed, etc. For this functionality the function attachInterrupt() is used
PWM: 3, 5, 6, 9, 10, 11 Pulse Width Modulation (PWM) pins are used to provide 8-bit PWM signal that often can be used for motor control or other specific use cases. For this functionality the analogWrite() function is used
SPI: 10(SS), 11(MOSI), 12(MISO), 13(SCK) Pins that support Serial Peripheral Interface (SPI) communications. For this feature, the SPI library is used
LED: 13 This pin is used to manage the built-in LED. LED can be turned on by setting the value of pin HIGH and turned off by setting pin value LOW
A4(SDA) and A5(SCL) Two Wire Interface (TWI) pins, Serial Data Line (SDA) and Serial Clock Line (SCL), are the alternative of the data exchange using serial communication. For supporting TWI, the Wire library should be used
AREF It is the reference voltage for the analogue inputs. For this functionality analogReference() is used
Reset Gives the opportunity to reset the microcontroller by setting this pin to LOW
Installing the Programming Environment

To start the development of software for a microcontroller, it is necessary to install and properly configure the development environment that consists of the program editor and the Arduino UNO driver. Below are described all the steps that are needed to prepare the programming environment for Windows 10 OS.

Step 1. Preparing Arduino UNO and the USB Cable

Before installing the programming environment, it is necessary to prepare the Arduino UNO board and the USB cable for connecting the board to the computer.

 title
Figure 1: The Arduino UNO board.
 title
Figure 2: USB B cable for Arduino UNO.

Step 2. Downloading the Arduino Software Development Environment

The open-source Arduino Software (Integrated development environment (IDE)) can be found in the official Arduino website [1]. The appropriate installation file depends on the OS of the computer and the access rights of the user.

 title
Figure 3: Downloading the installation file for Windows OS from Arduino original website.

For Windows OS, the Windows Installer should be clicked, and then the file should be saved on the computer. When the installation file has downloaded, the file should be run. If the ZIP file was downloaded, it is necessary to unarchive it and to run the installer. Follow the instructions of the installer. If the operating system asks for permission to install the driver of the board – allow it.

It is also possible to use Arduino Web Editor (can be found on the same website) to work online with the Arduino board, but this option will not be considered in this manual.

 title
Figure 4: Arduino Web Editor.

Step 3. Connecting to Arduino

Using USB cable, Arduino needs to be connected to a free USB port of a computer. The blue LED on the Arduino board starts to shine continuously. Aforementioned is the indicator that the Arduino board is working.

The green LED will blink, and that will indicate the performance of the manufacturer test software. In case if the green LED is not flashing, it is not an error.

Step 4. Starting Up the Programming Environment

The Arduino programming environment can be started with the double-click on the desktop shortcut of the Arduino software. The language of the environment will respond to the one that is set up in the OS of the computer, that means if it is English, then the menu of the programming environment will also be in the English language. To change the language preferences, it is necessary to follow the instructions in the following webpage [2].

Step 5. Open the Example Program

In the Arduino IDE open File → Examples → 01.Basics → Blink as shown in the image below.

 title
Figure 5: The path to open Blink example in the Arduino IDE.

This will open in the new window an example program for turning on and off green LED that is situated on the Arduino UNO board with the 1 second delay.

 title
Figure 6: The example Blink program.

Step 6. Choosing the Microcontroller

In this step it is necessary to choose the type of board that is used. In this example the Arduino UNO board is used that is why in the menu of Arduino IDE choose Tools → Board → Arduino/Genuino Uno as shown in the image below.

 title
Figure 7: The path to choose the type of board.

Step 7. Setting Up COM Port

To ensure transmitting and receiving data to/from the microcontroller, it is necessary to set the serial communication port – COM port. All ports are numbered in order, and for Arduino microcontroller, it is usually higher than COM3, i.e. COM4, COM5, etc. In the image below, it is COM4.

 title
Figure 8: The path to choose the port for Arduino connection.

Step 8. Uploading the Example Program to the Board

Now the program can be uploaded to the Arduino board using the Upload button in the top left corner of the software, then wait for a few seconds, during which you can see the data sending indicators – LEDs are blinking fast (indicates sending or receiving data) – and wait for the message to be “Upload is complete”.

 title
Figure 9: Uploading program to the board.

After a few seconds, the green LED will blink with a one-second interval like it is written in the source code. If this can be observed successfully, then everything is done to start learning the basics of programming.

In case if the blinking green LED cannot be observed, instructions for troubleshooting can be read in the following link [3].

If you want to get acquainted yourself with microcontroller capabilities or programming basics independently, look at one of these sources of information:

  • examples for the accomplishing tasks of different level of difficulty [4];
  • reference for the programming language used [5].

Check Yourself

1. What power supply Arduino UNO microcontroller requires?

2. How to operate with inputs/outputs of the microcontroller?

3. Try different examples in the menu of Arduino IDE.

en/iot-open/getting_familiar_with_your_hardware_rtu_itmo_sut/arduino_and_arduino_101_intel_curie/programming_fundamentals_rtu/setting_up_programming_environment.txt · Last modified: 2020/07/27 09:00 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0