Arduino - 2021 Updated User Guide to Learn Arduino Programming Step by Step
Arduino - 2021 Updated User Guide to Learn Arduino Programming Step by Step
Introduction
Concluding
Thank you for purchasing this book!
Joseph Marie Jacquard invented a punched card for the weaving machine in
1808, the French weaver. Although it was not a computer, it was an analog
to contemporary automatic lines, for the first time the programming
principle, in which modern robotics stands, was applied in the industry.
Over time, control methods, in particular wired and radio waves, have been
improved. In 1898, Nicola Tesla first demonstrated a self-propelled, radio-
controlled boat. At the same time, other devices have begun to acquire
simple and more powerful miniature electric motors instead of complex
mechanical drives.
All the factors leading to the formation of the first robots were already
established by the beginning of the 20th century. Electric current has not
only become a source of energy, but also a way of receiving, transmitting
and processing information. It is impossible to tell when the first robot
appeared, in the current context of the term. Many companies and
individual developers of that time worked on these machines. More than 30
mechanisms were developed in the 20s-30s of the last century that still
fulfill the demands of high-quality robotics.
However, this and many other robots were designed rather than for specific
practical activities to demonstrate scientific achievements. Later on,
robotics emerged in manufacturing or agriculture as such work required a
qualitatively new level of technology. Although the first prototype of an
industrial robot was founded in 1898, the manipulator created by American
engineer Babbitt pulled the blanks out of a red-hot furnace.
Only after the end of the Second World War did robotics grow entirely in
the industry.
General Electric created the first industrial robot to operate in a nuclear
reactor in the United States in 1948. Its feature was that the operator was
able to see its movement in the workspace but also to feel the strength that
had been developed by the manipulator's gripper which enabled the
mechanism to be controlled more accurately.
Today, nearly all fields of operations have been invaded by robots. Industry,
scientific research, energy, medicine, entertainment, military operations and
space – modern mechanisms are used extensively, either automatically or
remotely controlled, and human work is even increasingly overwhelmed.
Robots have been developed in several directions – improving mechanisms
and drives, improving algorithms, establishing control systems of self
learning (weak artificial intelligence) and developing new interfaces
between humans and computers. Biotechnology and cybernetics are closely
related to roboticism which leads to the development of cybernetic
organisms, functional bionic prostheses, fully autonomous cars, vessels,
spacecraft and aircraft (including military). So Karl Capek described our
society imperceptibly in the future only one century ago.
Now even a robot can be installed at home. Arduino is perfect for this
mission.
Chapter 1: What is Arduino and Why Should You Buy It?
What is a checker?
For all that have no insights into the subject: not to be mistaken with the
microcontroller - atmega is the crystal microcontroller, the PIC and other
"chips," and the controller is the board for which the microcontrolling is
soldered.
For those that have no idea: the controller is an electronic device that
controls something, i.e. by manipulating others, that reacts to changes in
certain parameters. Take the air conditioner on the wall, for example. There
is an intelligent control panel which switches the air on and off when
necessary, heating/cooling/dehumidification/humidification. A microwave
controller often regulates different tasks on the microwave oven.
Air conditioners, mp3 players, bike devices, sensors, smart phones,
browsers - many of them (usually) have advanced controllers. However, the
desktop machine is a basic controller that can also be extended and can be
used and incorporated with its support. Only suitable expansion cards and
software are required.
Arduino
Let's begin by knowing what we're going to do and what. What is and how
to use Arduino? If you already know the issue - you should easily hop on. If
not, let's swim together for a little period.
Arduino
Arduino's founders
In the potential, if the schools are carried away and the tests are to be
continued, the list of facilities must be broadened:
The monitors / Telescreens and indications / Telescopic motors and drives,
relays and engine drives / Telescopic contact systems / Numerous other
extension and card modules.
Chapter 3: Programming Languages for Arduino
WinAVR consists of the GNU GCC compiler that supports the C, C +, and
Objective-C languages, including complete AVR/AVR32 creation cycle and
additional resources, each with a particular task to write microcontroller
software. The most popular of them are: • Programmers Notepad - a
program editor • AVR-LibC - microcontroller library
• AVRDUDE - a computing chip tool with an SPI interface · GNU debug
(GDB) - Command line debugger • Insight - Interactive interface deployer •
Simulavr – GDB help microcontroller AVR • SRecord - a full collection of
EPROM boot files to operate with.
The package falls under the GNU license and is fully free to distribute. In
your discretion, each user may change or modify the software. Furthermore,
there is a compact variant of the store kit that does not include placement on
an external storage media. The WinAVR installation position address bar
does not have spaces or Cyrillic characters. After the software is mounted, a
whole set of shortcuts emerge, which launch different package utilities. The
key one is the "Notepad Operator."
Eric B. Weddington is the app creator.
Bloc of arduousness
Temporarily switch from adult languages into the cherished childish tongue
of Scratch - Ardublock. All here is the same, except with your platform
adaptation - colored bricks, builders, Russian titles, the most basic
reasoning. And for those who don't know about programming, this choice is
fantastic. Like the Emblem you can transfer a virtual bug to a virtual plane,
here you can interest the child in the actual understanding of his program
behavior with the aid of basic operations.
Yeah, by the way, you have to mount a plugin on your Arduino IDE
standard. The new models are better, not to skip, but very complicated. In
the beginning, the date of the end of 2013 is acceptable. Rename it for
"ardublock-all" to mount the downloaded file and push into the "My
Documents/Arduino/tools/ArduBlockTool/tool" folder. Build it if it doesn't
exist.
Snap!
In contrast with Ardublock, Snap! is able to utilize lists and functions in the
form of additional blocks. That is, Pop! is largely an adult programming
language, and does not count that you do have to play code constructor.
For the younger age group, people who learned programming too long ago
don't know something, or even people who want to tempt their kids with
Scratch and Snap!. It is recommended.
Snap! – is Scratch-based block programming framework at Berkeley
University of California (University of California at Berkeley).
Snap! was created by MioSoft Corporation's Ens Mönig, now SAP and
Berkeley's Brian Harvey.
Snap! from Scratch's biggest distinction are first-class data forms.
First class items are named elements to which a vector or element of an
array may be delegated, passed as a parameter and returned from a method.
This helps you to build two-dimensional arrays in Snap!.
Unlike the #Scratch features, first class artifacts are still in Snap! This helps
you to transfer a function to another function as a statement. In the
following example, the operation "Multiply by 10" is given as an argument
to the map function and this action is executed by the map function, with
the entire list as the second argument.
Another surprising distinction is that sprites are good performing objects as
well and can be passed as statements.
These features in Snap! encourage students to become acquainted with
practical programming as opposed to the normal Scratch programming.
Compatibility.
The Chrome edition 43 or higher (this is the browser suggested for Snap
work!)
· version of Safari not less than 8.4; • version of Firefox not below 38; >
version of Edge not less than 12; > version of the Firefox version not less
than 32;
Python
Formally in Arduino you should at least use Piet language so you can
compile everything into the computer code with sufficient perseverance.
However, since Python is one of the most common languages with a nearly
optimum combination of complexity/competency, its applicability in
Arduino will be incomprehensible to circumvent.
You use PySerial libraries (you may previously use them to connect with
device ports) and vPython to do this.
In Go, it is better to use the sio kit to operate with the serial port. This kit is
not physically quite big, but it is adequate to transmit and receive data from
the computer.
As Arduino works with Python through the PySerial library, so can Go, c
Java and HTML connect with anything you want. Arduino is quite
common, so that the option of a convenient language does not deter another
adventurer. The only thing the owner of this small board wants is to grasp a
remarkably fascinating thing, and a realistic method would eventually be
usable.
Chapter 4: Choosing Arduino
The option and purchasing of Arduino boards is not a major problem for
experienced electronics engineers who build a single project. Information
and skills help them to choose the right job choice. However, it may be hard
for robotic novices to select because the selection of boards is very diverse,
and there are also many analogs for each original.
Look at the number of Arduino in any specialized online shop. It may also
be very difficult to select a suitable cost from all the current variety, but it is
possible.
Arduino preference depending on the project
So, the first thing that determines Arduino's option is which project would
you implement?:
• рroject ready.
• independent project. independent project.
• not decided yet.
All is straightforward in the first case. Get the Arduino board originally
measured for the project.
When you put your own ideas into motion, start with any fee you want to
pay. After that, pick based on removal. That is, if you install modules with
contacts under Arduino Uno during the project, then you automatically
exclude ProMini or Micro, for example. After that, exclude the larger
Arduino from the project:
• Sizes
• Speed of the clock
• Number of results
• Stress
Note that the board memory size must be at least 30% of the required
project size.
If you are determined to find the best, concentrate on the feedback for
similar work on the Internet. Pay attention to the most famous at the same
time. It's most definitely the Arduino Uno, one of the oldest in the card line
and continuously upgraded.
xxx Arduino
The first boards were in this type factor and the most reincarnations
remained in this version (USB versions in chronological form):
You may not believe it, but only Leonardo demonstrates a tangible
difference for the consumer.
Next to Leonard and Uno the official site only offers for purchase, but
Duemilanove choices are overloaded on the Internet (our CraftDuino is just
its variety for good purpose – everything that the average consumer wants
have been integrated in Arduino Extreme already, and since then very little
has changed.
All of these cards have the same number of inputs and outputs, are placed
on the same connectors, are programmed via USB and have an ATMega
microcontrollers on board. ATMega8 was installed in earlier models,
ATMega168 was installed and ATMega328 was installed.
There are only 3 PWM outputs on "eight" and 8Kb under 1Kb RAM, but
that's enough for many applications. ATMega168 already has 6 PWM and
16Kb for your needs, the 328th has 32Kb and already has 2Kb of RAM for
programs. By the way, the user does not have all flash memory, and the
boot loader does take part. There was a USB-UART chip converter FT2322
on every board before the UNO, allowing you to stick the board directly to
USB and program it without a programmer. A virtual COM port was found
within the device and is used for programming by the Arduino development
environment.
The manufacturer suggests that the Arduino Starter Kit be used to learn
Arduino. In this package are included the board of Arduino UNO and other
electronics for the Arduino study: LEDs, resistors, servo drives, motors,
buttons, LCD panel, piezoelectrical modules, sensors and more.
You have to spend around € 80 to buy the Arduino Starter Kit from the
official manufacturer.
Analogs benefit greatly from similarly configured rates.
Almost all these sets contain the minimum required for beginners and are
suitable for learning our Arduino lessons for beginners (in small sets there
is often no photo resistor).
Arduino United
The board's benefit is its success. The majority of online lessons were
therefore developed for this reason, so there are plenty of comprehensive
usage details. The existence of the DIP panel and the ability to adjust the
microcontroller are also noted.
You won't be able to create circuits on the Breadboard from the
disadvantages. This can also be considered to be less than high.
It works as well as ProMini and UNO and can be used for creating
breadboard circuits. The board is much larger than the Arduino ProMini,
but has a USB port without the use of an external programmer.
There are a variety of inconveniences. First, it does not suit the shield
created under the Arduino UNO. Second, a USB port with a controller has
resulted in an increase in the amount of flash memory assigned to the boot
loader. This is worse than the ProMini Arduino.
Mega Arduino 2560
Model advantages:
• Shields for Uno suit the board
• Multiple connections
• High density memory.
The drawbacks are similar to those of Uno: the dimensions that are the
biggest of Arduino boards and the inability to create circuits on the
Breadboard.
Leonardo Arduino
The board is an updated version of Uno and most programs are compatible.
Furthermore, both shields are appropriate for Uno. The board also benefits
from simulating computer devices with a USB input like a keyboard, mouse
etc. Among the deficiencies is the inability to create circuits on the
breadboard and a rise in the share of memory used by the microcontroller to
move USB input functions.
This model provides the versatility of Uno and Nano, but can also be used
for Breadboard electronic circuits. It is small in size and can be soldered to
the board without contacts and with pin type. It makes the hinged
installation possible. The drawbacks include the failure to function with
Uno shields and the need to attach external programmers, since the board
has no USB controllers.
MICRO Arduino
The Arduino MICRO is as diverse as the Leonardo. The benefits here are:
ProMini Arduino 5V
The range of Arduino panels is very wide, so analyze all their advantages
and inconveniences when designing a project and buy an acceptable choice.
The best way to start with Arduino is to buy a finished robot. This is ideal
for children and very lazy beginners.
There are a wide number of Arduino-based kits. This way of exploring the
Arduino is better for young children because it is a finished toy in which
you can play and dismount and use the Arduino board and other
components during training.
Of course, in the beginner's lesson the finished robot does not have all the
data, but everything missing could be purchased separately. Easy DIY
components can be purchased from any store of radio components, such as
LEDs and resistors.
• If you haven't decided on a project but want to buy Arduino for your own
experiments, the number of different examples on the network, one or
another version of Arduino, should be taken into account. The undisputed
leader is Arduino UNO, since this board is the oldest and is not out of date
because it has undergone several changes since its inception.
•
If you are going to carry out your own project, Arduino should be chosen
using an elimination process. If your project has Arduino Uno output
modules, Arduino ProMini 3.3V, Arduino ProMini 5V, Arduino Nano and
Arduino MICRO are removed. If the modules are not usable, we exclude
Arduino which are not suitable in size and then Arduino which have more
than the number of outputs (digital, analog, PWM, interface), clock
frequency and voltage needed by the project. In that case, at least 30% of
the needed project must have a memory margin.
•
The case with analogs is slightly more complex. They have the same
designation as the original (such as xDuino UNO R3 CH340G and
DCcduino Uno R3 Ch340G) but may have a different form of USB
connector, slightly different lengths, a different type of USB controller, a
different type of microcontrol box, color of the panel etc. Here you can
understand that the boards repeat their original functionality (names that
mimic their own name), as they use the same ATmega microcontroller in
the same sequence. Photography may identify the size of the board, the
microcontroller case and the type of USB port. And with the "CH340G" in
the title you do not need to install the CH340G CH340G driver as a USB
controller for an Arduino, but its CH340G analog, to connect the Arduino
to your device. These boards are ideal for those who agree that installing a
once driver is not unpleasant and that reduced costs are a benefit over the
original name.
Chapter 5: The Theory of Creating a Robot Based on Arduino
Arduino Boards have several features, but it can be challenging for a novice
to begin with difficult tasks and let's begin with the easiest. We can start
with a beetle or a spider from a primitive robot whatever you want.
Setup
This is used once when the controller is powered up or after restarting. If
you just want the code to run once, it should be positioned exactly as in our
example. There are most frequently numerous forms of initialization
procedures. Our sketch is no exception: Digital Arduino contacts can be
used as inputs and outputs. In the configuration feature, pin 13 will serve as
the controller's digital output.
Now "fill in" our controller sketch. We don't need a programmer in this
situation. Arduino controllers include a special boot loader program, which
handles the device download code. To complete the sketch you only need a
USB cable and the File + U menu item (Ctrl + U) in the Arduino IDE.
Theory and reality
You can build several walking robots and they can all look different. A
robot might look like a man. This is regarded as a biped (2 legs). For most
species this may also be the template - 4 legs - quadrupled. The robot can
also be insect-like and have six legs - hexapod. And the coolest robot,
including crabs, spiders and scorpions, can be 8-legged - octopod.
In addition to the number of legs, it is necessary to configure each leg. The
key attribute of the foot is its number of degrees of freedom or its
proportions (DOF). The freedom level is the ability to transform or bend
around a single axis (or less often - to move progressively along it).
Obviously, if you're free, you can't go far on such a leg. Two-degree legs
(2DOF) already allow multi-legged robots to run, even though 2DOF
allows you to move the foot end in only one level freely. The "foot" is
pushed in 3D space in a 3D-foot (if, of course, not all three axes are
parallel). There are 4DOF legs that only make the legs more flexible and
moving. Insects have 4DOF-paws most often.
What does it mean to us? Each degree of freedom in cheap amateur robots
is realized by a single engine, or more precisely a servo drive. The
configuration of the leg determines the number of servos required.
Therefore, it takes 18 servo drives for 3DOF-hexapods, and 32 for 4DOF-
spider. Don't be afraid of the large number; the small servo drives used in
amateurs are very inexpensive. You can find them in online stores by
requesting a micro servo.
To program the servos, it is enough to know that the key work is already
done by a controller. It just takes a power supply and a digital signal to tell
the controller where we want to switch the drive shaft. Information about
their style is simple to find. Their protocol is the simplest of all optical
protocols of communication: pulse-width modulation - PWM. There is a
three pin connector to all simple servos: ground, +5V (voltage can differ
depending on size and power) and signal input. In two different ways,
Arduino controllers can produce such a signal. The first is a PWM hardware
which can be created by the chip itself on several of its digital I / O pins.
The latter is software. Software helps you to receive more PWM signals at
the same time than hardware. The Arduino offers a handy wrapper - Servo
library. You can simultaneously use 12 servo devices on most of the smaller
controllers (Uno, Due, Nano) and 48 servo devices on and around Arduino
Mega. The servo's signal touch is related to the digital output of Arduino.
Earth and power - obviously, they are common to all servos to land and
power. On three wired servo drives, the ground is black or brown, in the
center is normally red + 5 V and, eventually, the signal is white or yellow.
Management from a software point of view is extremely simple:
Most servo drives will rotate the shaft to 180° and the middle position is
90° for them. Many solutions are available to simplify servo drive
connections to the Arduino board. The most commonly used is the Sensors
Shield. You can attach your connectors to it directly when you mount it on
an Arduino Uno and use power on the servers on the terminals.
Nutrition is another critical problem. You can use a single power source, but
it has to be a very powerful power source because you have a multifunction
board that allows the whole device to be supplied with one power line.
There are several different sources of influence. The choice is enormous but
the best one for radio models is Li-Ion / Li-Po briquettes. You would
certainly need special loaders for these models if you plan to use them.
When you choose a simpler controller, such as Uno/Due/Nano, you can
power it separately with a 9-volt-source, for example, then connect the
servos to the main power battery. If you follow my advice, food will be
adequate. You need to be much more vigilant than normal if you want to
use lithium batteries to regulate the voltage so that there is no over-
discharge. To do so, you should explain the permissible voltage for a
specific form of battery immediately. To accomplish this, a small digital
voltmeter must be connected to the robot. This will be further discussed.
Chapter 6: Simple Robots for You
You need to get all ready before you start the first assembly of your first
robot. You certainly have to verify what you have. To make it simple, pick
the Arduino Uno Controller for the first time. That's the example we used.
You will need 3 servomotor bits. Do not forget the battery compartment
with a click for the "Crown." You naturally have to mount a Krona battery
in this compartment. You need an infrarot receiver, too. Do not forget steel
wire of approximately 1.5 mm diameter. For the equipment you need a
soldering iron and everything you need to solder. No need to solder a lot
and no special expertise is required. If you don't have soldering iron, you're
going to have to buy it because you want to buy more after you have made
your first robot. You certainly have to have a glue weapon and rods. Do not
forget to work with the wire pin. When everyone is gathered, it's time to
begin.
First of all, we must learn how to use the control panel and know the codes
to operate our console and robot correctly. These codes are then useful for
the sketch of the robot power.
You will need an infrared receiver and prototype board at this stage of
production. I hope that no one is worried that almost all remote controls and
infrarot remotes operate in 36 kHz, 38 kHz or 40 kHz carrier frequencies.
Each infrarot receiver is usually very suitable for us at 36, 38 or 40 kHz.
The frequency may not exactly correspond to the signal carrier frequency.
In this case, the recipient's sensitivity decreases, but in practice, this is
mostly not noticed.
Therefore, TSOP21xx, TSOP22xx, TSOP312xx, are suitable for most
remote receivers. The last two numbers may be 36, 37, 38 or 40. You can
specify the position of its contacts before turning on the Infrared receiver -
there are only three:
• 1 - turn left • 2 - step forward • 3 - turn right • 4 - turn left at the spot • 5 -
turn right • 6 - turn backward at the spot • 7 - backward at a right turn • 8 -
backward at a turn • 9 - backward at a left turn • very slow • yellow –
slowly – green • rapid • red – very fast.
Write down the codes for these buttons and they are later needed for a robot
control sketch.
Algorithm of motion
Now let's assemble the robot on the board of prototypes and add a sketch.
This is a very critical pre-assembly level. Try disconnecting the USB cable
and adding power to the "Krona" battery layout. Test all movement phases
to make sure it works. It will be harder to alter anything after the robot is
assembled (for example, to replace an idle servomotor).
We switch now to the assembly. The battery compartment is the main
carrier. I recommend that you use a locked cabinet and always use a key.
The details of the beetle can be quickly fastened using a glue gun. Begin
with servomotors. Remove unwanted lugs and join the devices. Then paste
this three-serve motor assembly into the battery cabinet lid. Remember to
open the battery compartment to change the battery.
It is easier to paste the controller into the battery compartment, but I really
do not like this choice because I will still have to send the Arduino Uno to
the beetle. You may then complicate your life and use the Arduino
connectors to link to the battery portion. Paste the male connector with a
pitch of 2.54 mm on the bottom of the compartment. The control socket
should be located in the region of the digital pins 8–11. If the connector is
not usable, fit the curved paper clip in U-shape.
The wires must be wired to the Vin pins and adjacent GND in the battery
compartment. Don't deceive polarity! More "Krona" on wine, minus on
GND. To ensure secure contact of wires with Arduino connectors, wrap the
thicker tip of the wire and use a small piece of the paper clip instead of the
plug. Place the tube next to the soldering tube.
Servo connections should be cut off, the power wires (+5V – typically red
and GND – black or brown) should be combined and brought on the
controller to the 5V sockets and to the adjacent GND. We're going to talk
later. Signal control wires (normally yellow) are created to the digital output
of the controller: left servo motor pin 2, center pin 4 and right pin 7.
"+" and "-" INFRARED can be inserted in the Arduino connector (5V and
adjacent GND). Half bending doubles its thickness. We solder the
previously supplied control wires of the servomotors to the same power legs
of the INFRARED receiver. The INFRARED receiver's output signal is
unlikely to meet the A0 controller's Analog Input, so you have to increase
its cable.
Tips to make legs. Next, plan the "front-rear" legs left and right. Ensure that
they are symmetrical (pay attention to the lengths and angles of the bends).
Start gluing the legs only, make sure the servomotors are located "zero" (90
°).
It is safer to mount the medium legs last on average. I advise you first to
make the middle legs longer and then shorten them to the perfect length
after installation. All six legs have to stand on the surface in the "zero"
position. The "front-back" bends should not be messed with by the rolling
of the middle legs at a 15° amplitude.
Your robot can do a lot with the aid of Stomping Beetle. This is a mobile
platform, ready to use, based on one of the most common and affordable
controllers. You can add your robot features. If you add an infrarot
Directed, your robot will engage in the war against robots. The robot's
tactile sensors and range-finder can be linked. You may teach the robot to
circumvent obstacles or to follow a certain path. A camera can also be
mounted on the robot. All you need is a fantasy and a properly selected
collection of Arduino to successfully execute the idea.
Concluding