❓ How to start programming Arduino

❓ How to start programming Arduino

Daniil Zhuk

Want to learn how to create electronic gadgets with your own hands, but do not know where to start? Intend to learn the basics of electronics? Then Arduino family cards are a great choice for a beginner. In particular, the Arduino UNO board, which we will now consider, is good for this purpose.

Instructions for entering into Arduino programming


You will need:

  • Arduino UNO board;
  • A USB cable (USB A to USB B);
  • Light-emitting diode;
  • a pair of connecting wires with a length of 5-10 cm;
  • in the presence of - breadboard.

Download Arduino IDE

Download the development environment for Arduino (Arduino IDE) from the official website for your operating system (supports Windows, Mac OS X, Linux). You can choose the Installer, you can archive (ZIP file for non-admin install). In the second case, the program simply runs from the folder, without installation. The downloaded file contains, in addition to the development environment, drivers for Arduino family cards.

Connection of Arduino to the computer

Connect the Arduino board using a USB cable (type USB-A - USB-B) to the computer. The green ON LED on the board should come on.

Installing the driver for Arduino

Install the driver for Arduino. Consider the installation option on the Windows operating system. To do this, wait until the operating system prompts you to install the driver. Give up. Press the Win + Pause keys, launch the Device Manager. Find the "Ports (COM and LPT)" section. See there a port called Arduino UNO (COMxx). Right click on it and select Update Driver. Specify the operating system location of the driver. It is located in the drivers' subdirectory in the folder we just downloaded.

Remember the port to which the Arduino board is connected. To find out the port number, start the device manager and look for the "Ports (COM and LPT)" section. In brackets after the name of the board will be the port number. If the card is not listed, try disconnecting it from the computer and, after waiting a few seconds, reconnect.

Configuring Arduino IDE

Indicate your development environment to the board. To do this, in the Tools tab menu, select Arduino UNO.

Specify the number of the COM port to which the Arduino board is connected: Tools Port.

Open the sample program

The development environment already contains many examples of programs for studying the operation of the board. Open the "Blink" example: File Samples 01.Basics Blink.
By the way, programs for Arduino are called “sketches”.

Build a circuit with LED

Disconnect the Arduino from the computer. Assemble the circuit as shown in the figure. Please note that the short leg of the LED must be connected to the GND pin, the long one to the digital pin “13” of the Arduino board. It is convenient to use a breadboard, but in case of its absence, connect the wires with a twist.

Digital pin "13" has a built-in resistor on the board. Therefore, it is not necessary to use an external current-limiting resistor when connecting the LED to the board. When connecting the LED to any other Arduino pins, the use of a resistor is mandatory, otherwise, you will burn the LED, and in the worst case, the port of Arduino to which the LED is connected!

Download a sketch in memory of Arduino

Now you can load the program into the board memory. Connect the board to the computer, wait a few seconds while the board is initializing. Click the Download button, and your sketch will be recorded in the memory of the Arduino board. The LED should start to wink at you at intervals of 2 seconds (1 second is lit, 1 is off). Below is the code for our first program for Arduino.

void setup() {
    pinMode(13, OUTPUT); 
}

void loop() { 
    digitalWrite(13, HIGH);   
    delay(1000);                
digitalWrite(13, LOW); delay(1000); }

Read the comments in the text of the program - they are enough to deal with our first experiment. First, we describe the setup () initialization block, in which we set the initial values ​​of the variables and the functions of the Arduino outputs. This is followed by an endless loop of loop() that repeats over and over again while the board is powered up. In this cycle, we perform all the necessary actions. In this case - we light and extinguish the LED. The delay () operator sets the execution duration (in milliseconds) of the previous statement. The digitalWrite () operator tells Arduino which terminal to apply voltage to, and which voltage level it is.
Your first sketch is ready!

Helpful advice


In the network, there are many sites dedicated to working with boards of the Arduino family. Read, learn, do not be afraid to experiment and learn new things! This is an exciting and useful activity that will bring you much pleasure.

note


Be careful when working with the Arduino board - this is an electronic product that requires careful handling. There are exposed conductors on the bottom of the board, and if you put the board on a conductive surface, there is a possibility of burning the board. Also, do not touch the board with wet or wet hands and avoid wet areas when working.

Add a comment

* Comments must be approved before being displayed.