Hello everyone! In this tutorial, I will tell you what is Arduino board, how to work with Arduino and I will write a simple program, how to blink an LED, and communicate with the board. If you know the basics of working with Arduino, move on to the next lessons. So, let’s get started.
Arduino is an open-source circuit board with a microprocessor and memory. The board also has input/output pins for communication with LEDs, sensors, motors, kettles, routers, and everything that works on electricity.
You can download a program that will manage all these devices according to an algorithm. You can create an infinite number of unique cool gadgets made by yourself and on your own idea.
Power can be supplied via USB Type B, or through an external power input, recommended from 7 to 12 volts. UNO has another input for external power, most laptop chargers are suitable for it. The platform itself selects the optimal source if there are several at the same time.
There is a 5-volt pin on the board to power external sources (displays, buttons, etc.), and also a 3.3-volt output, 3 pins to ground. Here is the reset output to programmatically restart the board. The hardware board reboots with this button. The board has 14 digital and 6 analog inputs/outputs called pins. 0 and 1 (RX and TX) are digital pins used to exchange data with external devices.
Digital and Analog pins
A digital pin can measure voltage, but can only report on the presence or absence, and the lack of voltage reports as from 0 to 2 volts.
You can get 1 from the input using the digitalRead (pin) function if more than 4 volts are supplied to the input;
Using the command digitalWrite(pin); 5 volts are applied to the pin, wherein parentheses the pin number and the value is 1 or 0, this means a high or low signal. Digital pins are used to connect standard sensors or modules.
The analog pin works differently. It accepts voltage from 0 to 5 volts to the input, and the controller, by analogRead(pin); command, converts this value to a range from 0 to 1023.
In output mode, it gives up to 5 volts, but you can report it with a value from 0 to 255 using the analogWrite(pin); command, where the number of the pin and the value is in parentheses. The analog input is used to read analog sensors, such as photoresistors, a variable resistor. An analog pin does not require setting an operating mode.
Arduino also has open-source software that makes it easy to write code, verify, compile and upload it to the board for stand-alone use. The Arduino IDE runs on the Java Platform and supports the Languages C and C++ to upload into the Arduino boards.
In the tools, select your model of the board, and in the port, tab selects the port to which the board is attached. The setup block code is executed once at boot time, and in the loop block, everything will be repeated in a circle. To compile and download the program to the board, you need to click the download button.
Blink the LED
Now we can start writing a simple firmware. Let’s blink the LED. All Arduino tutorial begins with this program.
First, set the output mode for pin 13. In the main loop of the program, we light the LED. A voltage of 5 volts appears at output 13. The LED lights up. Then we turn off the LED. Changing the output voltage to 0 volts, we turned off the LED. To notice the switch, we introduce a delay using the delay () function. We connect the LED to the 13th pin with a long leg and connect the short leg to the ground. Then we connect the controller via a USB cable to the computer and load the code below on the Arduino. Let’s Make the LED light up for 3 seconds and turn off for 1 second. To do this, change the value of the delay function. Here’s what happened.
We will communicate with Arduino through the com-port. The LED will turn on and off at the command of the keyboard.
I will tell you more about com-port in the following lessons, now the task is to understand the possibilities. First, create the Light variable. We establish a connection with Arduino using the serial.begin(speed); function and set the speed. Declare pin 13 as an output. Then we check if any commands are coming in and write the received command to the light variable. If value 1 – turn on the LED, if value 2 – turn off. Just like that, you can chat with our Arduino.
This was the first lesson in Arduino. I advise you to go to the official website and write out all the teams, there are not so many of them. Thanks for reading!