create account

[EN]Getting Started with Arduino by robotics101

View this thread on: hive.blogpeakd.comecency.com
· @robotics101 ·
$9.84
[EN]Getting Started with Arduino
![4_arduino_EN.jpg](https://res.cloudinary.com/hpiynhbhq/image/upload/v1518389459/fwqvcodrmpudrf60u2m3.jpg)

In this article, I will try to show you how to use Arduino so that we can move on to more interesting things. If you ever have any problems or if you want more explanations, don't hesitate to tell me in the comments!

# The choice of the card:

When you choose to work with Arduino (if you haven't already made your choice, you can read [this article](https://busy.org/steemstem/@robotics101/en-raspberry-pi-vs-arduino-which-one-to-choose) you can choose between different boards (see the [Arduino.cc website](https://arduino.cc) for the [full list](https://www.arduino.cc/en/Main/Products)) of which the 3 most known:

- **Arduino Uno**: Perfect for beginners and practical to use
- **Arduino Nano**: Compact and breadboard compatible (we'll see below what it means), perfect for prototyping or for small spaces.
- **Arduino Mega**: More GPIO if your project requires it, a Mega saves you from having to take several cards.

![4_arduino_arduinos. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778415/mdfcqhhml9hi2g5vqwex.jpg)

If these little descriptions are not enough for you to make your decision, feel free to take a look at [this page](http://www.robot-maker.com/ouvrages/tuto-arduino/choisir-carte-arduino-adaptee/) and the product sheets available on [Arduino.cc](arduino. cc).

And to finish this first part, a little point about clones. As I explained to you in the [first article (Raspberry Pi vs. Arduino)](https://steemit.com/steemstem/@robotics101/en-raspberry-pi-vs-arduino-which-one-to-choose) Arduino is open-source so there are a multitude of manufacturers, so there is a multitude of prices too (and which can vary from $25 for an "official" Arduino UNO card to $2 for a cloned Arduino card in China). I've rarely had problems with clones but the main drawbacks are the delivery times (which can exceed 2 months) and the quality of the after-sales service, so pay attention to the reviews when you buy in China.

# Installation of the IDE:

<center>![ss (2018-02-04 at 07.50.56. png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517770287/luiixbdwcie49psvctxv.png)</center>
<center>Screenshot of Arduino IDE</center>

Arduino IDE is a software developed by Arduino to simplify the programming of its cards, it includes everything you need to program, debug and communicate with your card. Installation is easy, whether you are on Windows, Linux or Mac.

To start, go to the [download](https://www.arduino.cc/en/Main/Software) page and check that the selected hardware is yours and download the installer.

Once installed you will be able to use the integrated editor for:

- Write your programs with the text editor,
- Find bugs in your programs, 
- Compile your programs (roughly, the compilation turns a "text file" into an executable program),
- Communicate with your Arduino card: to send it a new program or to send/receive information)
- Easily install libraries.

# More on the board :

Before I start I will give you some details about the Arduino UNO card.

Two rows of pins on either side of the board allow you to interact with the different components you will use. There are different types of them and they are called this way:

- D0->D13 pins are digital inputs/outputs, i. e. they can be used to read or "write" (apply a potential) of 0V or 5V.
- The pins A0->A5 are analog inputs, these pins can read the value of a voltage varying between 0 and 5V on a resolution of 1024 values (0V = 0 and 5V = 1024) which means that these pins have an accuracy of 4.88mV (5/1024 = 4.88*10^-3 V).
- The power supply pins, located above the analogical pins they allow to power your electrical circuits you will find potentials of 5V, 3.3V, GND (ground), and a VIN pin (for V in, it can be used to power your card, it is an alternative to the USB cable and jack) (we will not use the rest for the moment).

![4_arduino_carte_EN.jpg](https://res.cloudinary.com/hpiynhbhq/image/upload/v1518389751/h674n03dwh4jhg7q0yhj.jpg)

# Basic components:

Here is a quick summary of the components we will use for the next 2 examples:

## Breadboards:

It's not really a component because breadboards allow making circuits easily without having to solder the different components. They are often used in prototyping phases and come in different sizes:

![4_arduino_breadboards. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778625/b2xmk2zfdeihgsutqpxr.jpg)

The breadboard holes are connected in a certain way that you will have to keep in mind to make your own assembling:

<center>![4_arduino_breadbord_pattern. png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517772012/a26mnalywbmxjdheyrz4.png)</center>
<center>Photo of 2 breadboards of different sizes</center>.

Once the prototyping is done we use this kind of boards to solder the circuit or we draw our printed circuits boards (PCB).

![4_arduino_veroboard. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778674/miafoj2v000jugxnk0is.jpg)

I said in the first part that the Arduino Nano was compatible breadboard, it simply means that you can insert it on a breadboard like this:

![4_arduino_nano. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778763/qnbu3sfc916fwornvji2.jpg)

## The LEDs:

![4_arduino_led. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778823/t9mudxidjjakkrwqe1pz.jpg)

LEDs are components that emit light when a current passes through them. One of the characteristics of an LED is that it can only let the current flow in one direction (from the positive pole called anode to the negative pole called cathode), the other direction block the current.

<center>![4_arduino_led_schem. png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517774768/w7qlatsymaxzlanjyzcp.png)</center>
<center>Image from [Wikipedia](https://en.wikipedia.org/wiki/File:LED, _5mm, _green_ (en). svg)</center>

When used with an Arduino (operating at 5V) a 220 Ohm (minimum) resistor must be added in order not to exceed the permissible current. If the permissible current is exceeded, the LED break and there is a good chance that you will no longer be able to use the pins on which it was plugged in.

>**Fun Fact**: The first LED was discovered in 1907, the first red led was invented in 1962. At that time the choice of colors was rather limited: Red, Yellow or Green. It was not until 1972 that researchers invented blue LEDs (and 1990 to have bright blues), used to create white LEDs and RGB (Red Green Blue) which were used in the backlighting of screens or LCD screens. The researchers who created the blue led even received a Nobel Prize for their discovery. [Source 1](https://www.nobelprize.org/nobel_prizes/physics/laureates/2014/) [and 2](https://fr.wikipedia.org/wiki/Diode_%C3%A9lectroluminescent#History)

### The resistors:

![4_arduino_resistances. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517779013/g5ur4f8h4fhxw6emuksm.jpg)

The resistors are components without polarity (you can connect them in any direction you want) and are used to oppose a resistance R (in Ohm, noted Ω) to the current. It is this R that we find in the famous Ohm's law: U = R * I where U is the Voltage in volts (V) and I the current in amperes (A).

One of the peculiarities of resistors is the system used to mark the differents informations on the component, with colored "rings" around the component:

![4_arduino_res. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517779079/piltqi85kdufrrlgs6ff.jpg)

There is a color code, but I don't think it's useful to learn it, use an application to find the different information you write down and remember the colors of the ones you use most often.

# Blink:

I think one of the best ways to learn how to program is practice so I move quickly to examples, but reassure you every line is explained. If you need explanations about a particular function, please have a look at [Arduino Reference](https://www.arduino.cc/reference/en/).

Blink is the electronic equivalent of a "Hello World" in programming, i. e. it's the first thing you do to make sure you understand how it works. The electronic circuit is very simple and consists of connecting a led and a resistor between pins 13 and GND and then creating a program to make it flash.

## Diagram:

To find out which way to connect the LED, look at the length of the legs (the longer the positive leg) or the flat present on the negative side.

![4_arduino_blink. png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517612545/pdr6uz4xlx3zmkgx7jx3.png)
<center>Schema with[Fritzing](http://fritzing.org/)</center>)

![4_arduino_blink_photo. JPG](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517775957/wm6gn97zscrbtg6csfna.jpg)

## Program:

You can find the code [on Github](https://gist.github.com/101Robotics/e96bb16fc94c5dd41ba23902825faf43).

What I call symbol in the above program is a preprocessor, it acts as a constant except that it is replaced at the time of compilation by the value assigned to it. As a result, it takes up less memory space and is perfect for assigning a name to a pin number. And just like constants, symbol names are in capital letters by convention.

# Hello World + Serial Interface:

The second example I wanted to give you is a little more advanced Hello World allowing you to see how the serial interface works, which is used to communicate your Arduino with your PC.

## Diagram:

For this example, you won't need anything to connect:)

## Program:

You can find the program on [GitHub](https://gist.github.com/101Robotics/26f90d4630423ae48c96cc07f4ac9606).

# Make a counter:

And finally here is an example illustrating different functionalities of Arduino. The purpose of this example is to make a counter using a pushbutton that can be set to increment or decrement using the serial interface.

## Diagram:

![4_arduino_counter. png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517770843/jofy77ld9vls5efxox2c.png)
<center>Schema with[Fritzing](http://fritzing.org/)</center>)

![4_arduino_counter_photo. jpg](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517779143/v9l1hwrb13bxcaukvmtl.jpg)

We can see on the diagram that I placed a 10kΩ (10 000Ω) resistor between the digital input (which is also connected to one of the tabs of the button) and the ground, this one is called pull-down and serves to avoid that the input acts like an antenna and catches the parasites (which would distort the measurement).

## Program:

You can find the code on[GitHub](https://gist.github.com/101Robotics/05f214a85f0e71994020129ce90d55d9).

I hope that this article will have you more and on this last example, I will tell you soon for a next article.

# To go further:

- [Tutorials Arduino. cc](https://www.arduino.cc/en/Tutorial/HomePage) as well as the examples provided with the IDE
- [Arduino projects on Hackster](https://www.hackster.io/arduino/projects)
- [Arduino Reference](https://www.arduino.cc/en/Reference/)

# Sources:

- [Arduino. cc](https://arduino.cc) and in particular[this page](https://store.arduino.cc/arduino-uno-rev3) and the examples provided.
- [Arduino Reference](https://www.arduino.cc/en/Reference/)
- [[FR]Course on C -> Preprocessors](https://openclassrooms.com/courses/apprenez-a-programmer-en-c/le-preprocesseur)
- Engineering Science at High School +  Electronics course
-[ Wikipedia: Resitor](https://fr.wikipedia.org/wiki/R%C3%A9sistance_ (component)),[LEDs](https://fr.wikipedia.org/wiki/Diode_%C3%A9lectroluminescent)
- [The First Blue Led](https://spectrum.ieee.org/tech-talk/tech-history/silicon-revolution/rcas-forgotten-work-on-the-blue-led)

👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 9 others
properties (23)
authorrobotics101
permlinken-getting-started-with-arduino
categorysteemstem
json_metadata{"community":"busy","app":"busy/2.3.0","format":"markdown","tags":["steemstem","arduino","busy","technology","diy"],"users":["robotics101"],"links":["https://busy.org/steemstem/@robotics101/en-raspberry-pi-vs-arduino-which-one-to-choose","https://arduino.cc","https://www.arduino.cc/en/Main/Products","http://www.robot-maker.com/ouvrages/tuto-arduino/choisir-carte-arduino-adaptee/","https://steemit.com/steemstem/@robotics101/en-raspberry-pi-vs-arduino-which-one-to-choose","https://www.arduino.cc/en/Main/Software","https://en.wikipedia.org/wiki/File:LED","https://www.nobelprize.org/nobel_prizes/physics/laureates/2014/","https://fr.wikipedia.org/wiki/Diode_%C3%A9lectroluminescent#History","https://www.arduino.cc/reference/en/"],"image":["https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1518389459/fwqvcodrmpudrf60u2m3.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778415/mdfcqhhml9hi2g5vqwex.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517770287/luiixbdwcie49psvctxv.png","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1518389751/h674n03dwh4jhg7q0yhj.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778625/b2xmk2zfdeihgsutqpxr.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517772012/a26mnalywbmxjdheyrz4.png","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778674/miafoj2v000jugxnk0is.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778763/qnbu3sfc916fwornvji2.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517778823/t9mudxidjjakkrwqe1pz.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517774768/w7qlatsymaxzlanjyzcp.png","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517779013/g5ur4f8h4fhxw6emuksm.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517779079/piltqi85kdufrrlgs6ff.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517612545/pdr6uz4xlx3zmkgx7jx3.png","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517775957/wm6gn97zscrbtg6csfna.jpg","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517770843/jofy77ld9vls5efxox2c.png","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1517779143/v9l1hwrb13bxcaukvmtl.jpg"]}
created2018-02-11 23:22:57
last_update2018-02-11 23:22:57
depth0
children6
last_payout2018-02-18 23:22:57
cashout_time1969-12-31 23:59:59
total_payout_value7.568 HBD
curator_payout_value2.270 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11,718
author_reputation13,003,325,382,700
root_title"[EN]Getting Started with Arduino"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,781,041
net_rshares1,333,958,849,728
author_curate_reward""
vote details (73)
@sideshow2 ·
Awesome intro, review, and info. I love making stuff with Arduino. I will definitely follow and look forward to seeing more.
properties (22)
authorsideshow2
permlinkre-robotics101-en-getting-started-with-arduino-20180212t012323350z
categorysteemstem
json_metadata{"tags":["steemstem"],"app":"steemit/0.1"}
created2018-02-12 01:23:24
last_update2018-02-12 01:23:24
depth1
children1
last_payout2018-02-19 01:23:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length124
author_reputation13,138,324,409
root_title"[EN]Getting Started with Arduino"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,800,955
net_rshares0
@robotics101 ·
Thank you ! :)
properties (22)
authorrobotics101
permlinkre-sideshow2-2018212t183741352z
categorysteemstem
json_metadata{"tags":["steemstem"],"app":"esteem/1.5.1","format":"markdown+html","community":"esteem"}
created2018-02-12 17:37:45
last_update2018-02-12 17:37:45
depth2
children0
last_payout2018-02-19 17:37:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length14
author_reputation13,003,325,382,700
root_title"[EN]Getting Started with Arduino"
beneficiaries
0.
accountesteemapp
weight1,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,989,185
net_rshares0
@steemitboard ·
Congratulations @robotics101! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png)](http://steemitboard.com/@robotics101) Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard)

If you no longer want to receive notifications, reply to this comment with the word `STOP`

> Upvote this notification to help all Steemit users. Learn why [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-robotics101-20180223t070433000z
categorysteemstem
json_metadata{"image":["https://steemitboard.com/img/notifications.png"]}
created2018-02-23 07:04:33
last_update2018-02-23 07:04:33
depth1
children0
last_payout2018-03-02 07:04:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length681
author_reputation38,975,615,169,260
root_title"[EN]Getting Started with Arduino"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,797,421
net_rshares0
@steemitboard ·
Congratulations @robotics101! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png)](http://steemitboard.com/@robotics101) Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard)

If you no longer want to receive notifications, reply to this comment with the word `STOP`

> Upvote this notification to help all Steemit users. Learn why [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-robotics101-20180224t060709000z
categorysteemstem
json_metadata{"image":["https://steemitboard.com/img/notifications.png"]}
created2018-02-24 06:07:09
last_update2018-02-24 06:07:09
depth1
children0
last_payout2018-03-03 06:07:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length681
author_reputation38,975,615,169,260
root_title"[EN]Getting Started with Arduino"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id40,018,550
net_rshares0
@steemmakers ·
$0.02
Congratulations! This post has been upvoted by SteemMakers. We are a community based project that aims to support makers and DIYers on the blockchain in every way possible. Find out more about us on our website: [www.steemmakers.com](www.steemmakers.com). <br/><br/>If you like our work, please consider upvoting this comment to support the growth of our community. Thank you.
👍  
properties (23)
authorsteemmakers
permlinkre-robotics101-en-getting-started-with-arduino-20180213t081835314z
categorysteemstem
json_metadata""
created2018-02-13 08:17:54
last_update2018-02-13 08:17:54
depth1
children0
last_payout2018-02-20 08:17:54
cashout_time1969-12-31 23:59:59
total_payout_value0.020 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length376
author_reputation1,907,312,584,548
root_title"[EN]Getting Started with Arduino"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id37,155,228
net_rshares3,332,137,799
author_curate_reward""
vote details (1)
@steemstem-bot ·
$0.92
This is a test comment, notify @kryzsec on discord if there are any errors please.<br><center><a href="www.steemit.com/@steemstem"><img src="https://media.discordapp.net/attachments/384404201544876032/405507994583957505/steemSTEM.png"></a><br><table><tr><th> </th><th> </th><th><a href="https://steemit.com/steemstem/@steemstem/helpful-guidelines-for-crafting-steemstem-content">Guidelines</a></th><th><a href="https://steemit.com/steemstem/@steemstem/steemstem-winter-2017-2018-project-update">Project Update</a></th><th> </th><th> </th></tr></table><br><a href="https://steemit.com/steemstem/@steemstem/being-a-member-of-the-steemstem-community"><b>Being A SteemStem Member</b></a></center>
👍  ,
properties (23)
authorsteemstem-bot
permlinkre-en-getting-started-with-arduino-20180213t193840
categorysteemstem
json_metadata""
created2018-02-13 19:38:42
last_update2018-02-13 19:38:42
depth1
children0
last_payout2018-02-20 19:38:42
cashout_time1969-12-31 23:59:59
total_payout_value0.924 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length692
author_reputation3,811,533,615,496
root_title"[EN]Getting Started with Arduino"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id37,287,782
net_rshares131,305,396,954
author_curate_reward""
vote details (2)