Transcripts
1. Introduction: Welcome and thank you very
much for choosing this course. In this Arduino
beginner's guide, you will find an introduction
to the use of the mini PCI Arduino in
theory and practice. I, as an engineer, will share with you my
knowledge from study and practice step-by-step
in this course, this course aimed
specifically at beginners, you will learn all
the basics you need to know when working
with an Arduino. We will work exclusively with the Arduino Uno in this course, as it is ideally
suited for beginners. In brief, this course will teach you the
following in detail. The basic terms
and components of electrical engineering
as background knowledge, structure of an Arduino Uno
board and how to use it. What is the Arduino IDE? What is it used for and
how is it structured? Programming Basics,
block-based programming, programming basis,
text-based programming. How to create a system
with an Arduino, and how to write the
required program code. Hence, on learning based on exciting Do It Yourself project. Sos signal with LED, temperature based LED control, dependent control of a motor, gas detection alarm,
password protected system, remote control system, and
much more. Be excited. Let's go.
2. First steps with an Arduino: Arduino is an electronic
platform consisting of hardware and software that
is very user friendly. And it was created as part
of an open-source project. The term open
source is generally characterized by the fact that software is freely available, active participation
of users is desired, and there are no
restrictions on use. Simply put, an Arduino
is nothing more than a small and very simple PC or microcontroller that is capable
of taking input signals, processing them
internally, and then converting them into
corresponding output signals. An input signal
could, for example, be sunlight falling
on the center. The corresponding
output signal it could, for example, be
controlling a motor. This mini PCI can
be purchased in the very realistic appearance of a circuit port equipped
with electronic components, either individually
or as I said. There are different
Arduino boards, modules and beginner sets. The following Arduino boards are recommended to get started with. Arduino, Arduino Nano, Arduino
Leonardo Arduino Micro. A good overview of all
products and the weight to all of them can be found
on the official website, www dot arduino dot cc. You can either on the Arduino products we
need in this course, why at this official site or
buy them on Amazon or eBay? By the way, an Arduino Uno port is available from about $20. Complete starts to
set from about $70. In this course, we
will mainly deal with the Arduino Uno board and
use it for the projects. We will also need
other components, such as LEDs,
Resistors, sensors, for example, infrared
sensor actuators, for example, a motor
for the project. Which components in
particular are needed. You will find them
the further course and then each project
clearly listed. For this, it is
recommended to buy the so-called arduino
starter kit for beginners. Or also another star to set, or in addition to the
Arduino Uno board, also sensor or module set, which contains the
required components in order for the mini PC to know what to do with the previously
mentioned input signals and output signals, we would like to have the Arduino board
needs instructions. These instructions for
the microcontroller are given by the user, that means by us, thanks to a program code. Programming language is
used for this purpose. For programming
and transmission, a special software is used, the Arduino software IDE. This software can be downloaded
online free of charge. For example, at arduino dot cc, countless projects
have already been realized with the
Arduino microcontroller. This mini PCI is suitable
for hobby projects, for prototyping or even
for a scientific projects. The Arduino community
spread all over the world. It includes students, engineers, hobbyists, artists,
programmers, and so on. Millions of users have contributed to this
open-source platform. And thanks to these
contributions, a lot of knowledge has been accumulated to help
professional and new uses. There are various projects are doing you is
specifically designed for users who need a simple
and inexpensive platform for electronics and
programming projects. Since Arduino is an
open source project, uses can change
anything they want or customize any function
according to their needs. Why choose an Arduino? There are also other microcontroller platforms
and competing products. Some of them that are similar to Arduino are
called, for example, basic stamp by parallax, px 24, phi and handy board. And there are many other
boards with similar functions. However, these
microcontrollers use quite old fashioned
programming methods. The community is not as
large as for Arduino, and the instructions are not
so easy for new chemists. The following is a brief
list of why Arduino is so great and why you are right to choose Arduino
and this course. Reasonable price are doing new has a fair reasonable price. And this is one of
the main reasons for it worldwide success. The Arduino Uno
board, for example, is already available for around
20 bucks cross-platform. As with many major platforms, most microcontrollers
only work with Windows. They lack support for
systems like Mac and Linux. Arduino, on the other hand, runs with all systems
easy to program. Probably the most
important point. An Arduino is effortless to use and program the software for it. Arduino IDE is very
user-friendly. This helps especially beginners, but also young people
are retirees to get familiar with the program
very easily and playfully. Nevertheless,
Arduino also offers the possibility to perform complex projects and programming is also a great platform
for advanced users. Open source software. Everyone can contribute
to this great project. Every user can create
new libraries. We will learn later
what this is and make them available to
other users as well. Open source hardware. The Arduino hardware is also open source and
can be modified by any user through a kind of plug-and-play system and
through a so-called breadboard, modules can be
added in a variety of different projects
can be implemented. It is a kind of modular system.
3. Basics of electricity and digital electronics: Before we go into detail about the Arduino board and
the Arduino software. Let's first take a
look at the basics of electricity and
ticket electronics. Electricity is created by electrons flowing from a
place with higher potential, higher energy to a place with lower potential,
lower energy. It can be relatively well imagined by means
of a waterfall. The water represents the electrons flows from the
top point of the waterfall, high potential, high energy to the bottom point
of the waterfall. Low potential, low energy. The potential energy
is transformed into kinetic energy
during this process. That's why it loses this in
a T state in the process. But actually this energy is
transformed asset before. Similarly, d electron wants to flow from a place
with higher current, high potential to a place with lower current, low potential. Voltage is the unit of electrical energy
generated by the battery. The battery or any
other voltage source has two terminals. One terminal is called
the negative terminal, and the other terminal is
called the positive terminal. The positive terminal, the voltage potential is higher than compared
to the negative side. Thus, the current flows
from the positive side plus pole to the negative
side minus pole. Considering the technical
direction of current, you can think of a battery or other power generating source. Functioning as a pump. Battery, for example,
generates voltage or energy through an
electric chemical reaction. Inside this voltage, or energy flows out of the positive pole
in the form of electrons. These electrons symbolize
the water molecules that are pumped out to compensate
for the lost electrons. The battery, similar
to a suction pump, draws the same
number of electrons back in through
the negative pole. What is a circuit? Simply put, a circuit
is an arrangement of different components within the electrically conductive
connection between them. For an electrical circuit
or circuit to work, you need an energy source, such as a battery and a
load such as a light bulb, as well as connections
between these two components, which are called conductors. In electrical engineering,
these components are represented in a circuit
as the following symbols. For a lamp, for example, to light up as shown in
the following figure, the circuit must be closed. That means there must
be a connection between the two poles plus and
minus of a police source, for example, the
battery and the lab. If this is the case, current flows from one pole of the power source,
for example, the battery through the lamp, and back to the other
pole of the power source. When this connection is
severe, for example, by a switch, current no longer flows and the lamp
no longer lights. In this case, it is
called an open circuit. A short circuit occurs if
the current can flow from one pole of the current source to the other pole, unhindered. And without first passing through an electrical component. For example, through
an uninsulated spot of a cable on a metal surface. This is because
the current always takes the path of
least resistance. Circuit diagram is
the basic concept of a circuit that can be
drawn, for example, on a piece of paper or with the help of a
computer program, such as circuit diagram can also be made a bit
more descriptive, a bit more descriptive. Circuit diagrams for the
Arduino can be created best with the software
from Fritz Lang.org, which can be downloaded
at the given me URL for little money
at Fritz Lang.org. You can also find
many references and instructions for
using the software. As we can see on the picture in this project, for example, a relay and the
module are connected to an Arduino Uno wire cables. The colors of the
wires each have a meaning that helps to
make correct wiring. This illustration, or
red wires stands for the five volt signal and all black wires for the
ground signal 0 warm.
4. Important components of electronics & digital electronics: In this chapter,
we will deal with the basics of electronics, a main field of
electrical engineering. In particular, we will take a closer look at
digital electronics. Basis of digital electronics is simple switching operations. The computer is one of
the best examples of these switching operations
of digital electronics. The applications that
a modern computer enables us to do are achieved, thanks two switching operations performed by millions
of transistors. So what is the basic
principle behind the PC? Surely you have
heard this before. It is the so-called
binary system, which is based on
the two numbers, 01. Communication and
digital systems takes place with the
help of these numbers, with the help of
various combinations of these two numbers. Since the Arduino is
basically nothing more than a very simple
and strip down mini PC. This principle is
also applied here. The two binary
numbers are mostly represented in today's
electronic systems, but the voltage is five volt, one or high value, and 0 volt 0 or low-value. The restriction to
only two numbers or voltage values seems to
be very limiting and it is very hard to imagine
how a PC can achieve today's outstanding performance
based on this system. However, this system and
its simplicity makes sense. It simplifies the
matter because it is extremely simple to
recognize these two states. That means 0 or 12 definitely distinguish
them from each other. Diode is a semiconductor
component in electronics that has the property of
allowing current to flow in only one direction. For what direction? The other direction
is blocked for the current flow reverse direction. You can imagine a diode
simply like a valve. The simplest application
of a diode is the LED. Led light emitting diode is a semiconductor device that produces light when
it is energized. The light is produced
by current flowing from a DC source to the
diode and through it. Since an LED is a
semiconductor device, it also has a forward direction. This means that current can only flow through it in
that direction. If an LED is connected
incorrectly, no light will be produced. The color of the light and
whether it is visible or not. For example, infrared is controlled by the doping
and material used. Two major advantages
of LEDs are long life. Be low power consumption
compared to old-fashioned lamps. And LED can achieve a
lifetime of several, 10 thousand hours, and it has many times better efficiency. Why is that? Convention? Will
light bulbs produce an enormous amount of heat in
addition to visible light, which means that the energy expended is converted
not only into light, but primarily into heat. With LEDs, only a little heat is produced as a waste
or byproduct, and almost all the energy can be used to
produce the light. There are now different
types of LEDs. The simplest design is shown
in the presented image, the heart and also the actual semiconductor
element of the LED, shown is the LED chip, which is placed
on a reflector on the anode and the
midst of the light. The circuit symbol of
an LED consists of the diode circuit symbol with two additional
slanted arrows, which are supposed to
represent emitting light. Transistor is a simple three terminal component
that can best be thought of as a wealth that controls the flow
of water in a pump. For example. If we turn
the control wheel of their wealth in a certain
direction, that means open. The water flow increases. And if we turn it in the other direction,
that means close. The flow decreases. The valve in the case
of the transistor would be diets and the water
would be the current. Electronics and general
simplified has a lot to do with switching elements
and transistors also behave like switches. In addition to this
switching capability, transistors also have the
property of amplification, which would be equivalent
to changing the wealth for ASU for the amount
of motor output. This amplification property is particularly important in
the world of electronics. There are several
types of transistors. One of the simplest being
the bipolar transistor. Furthermore, there
are, for example, the field effect transistor and the metal oxide semiconductor
field effect transistor. All types of transistors have the special properties and are used in different
applications. In simple terms, a capacitor
consists of nothing more than two plates
arranged parallel to each other and the
dielectric between them. A dielectric is simply a weekly or
non-conductive substance, solid liquid gas with charge carriers that
are not free to move. Capacitors are generally
considered charge storage devices because when an electrical
potential is applied, they can store voltage and
not cheat in their plates. The ability of a
capacitor to store charge depends on the
area of the plates, the spacing and the a
dielectric between the plates. This ability to store charge is typically referred
to as capacitance. The charge in the
plates increases, so that's the voltage
of the capacitor, and this continues until
the capacitance is reached. Resistors are components that can be used primarily to
estimate name suggests, apply resistance to something. In this case, the
resistor acts against the current and can be used to limit the flow of current into a component that is
connected to the resistor. Basically, every conductor has a resistance that can be calculated depending on its
length and cross-section. In our case, we'll use
so-called sheet resistors. Here. For example, there
are the carbon foam or sisters and the metal or
metal oxide film resistors. With these types, the
resistance while you comes from Quranic core with a layer of carbon or metal or metal oxygen. The resistance value can be measured either with the help of a multi-meter or directly on the resistor by means
of a colored drinks. Each resistor has a
color-code consisting of five rings that revealed
the resistance value. How to read this color-coding
must be explained in detail and would therefore go beyond the scope
of this chapter. After all, we want to work with the Arduino as soon as possible. You can either look up this
coding online or best asset, use a multimeter to measure it. In electrical engineering, multimeters are often used
as measuring instruments. Multimeters with two terminals
and measure voltage, current, resistance,
capacitance, and inductance. But you can also
measure the polarity of transistors and perform a
continuity test with it. The continuous test tells us or whether a circuit
is shorted or not. Multimeters can only measure
one variable at a time, such as current or voltage. To measure are
multiple parameters. We need to use several
individual devices. The figure shows a
simple multi-meter with the different
measuring ranges. Depending on what
you want to measure, you turn the dial to
the appropriate range. When taking a measurement, always start from the
highest possible voltage or amperage, the highest or the
highest resistance value, and then turn the
display setting down until a suitable
value is displayed. This means, for example, that if you make a measurement
on a DC voltage source and you suspect a while
you between 2200 volts, you first turn the
setting range to 200 watts, and then downloads. If you want to
measure a voltage, you have to connect the
measuring electrodes parallel to the voltage source or to the component you
want to measure. As far a light bulb for example, this word work like this. If you want to
measure the current, you have to connect the
measuring instrument, the multi-meter, in
series to the consumer. That means disconnect the line. Perhaps you have heard the
term embedded system before. Perhaps you have
also often wondered what it actually is and
what it is used for. In simple terms,
an embedded system describes the presents of a type of computer in a technical system or
on a circuit board, as in the case of the Arduino, that carries out
signal transmission or data processing of input
and output signals. This processing is done
by a microcontroller, which is a tiny computer. This microcontroller is designed to perform certain functions, and it's basically
nothing more than a tiny computer system consisting of a
semiconductor chip. You can program the
microcontroller using PC software to
perform operations. As an example, in the figure, you can see a system
controlled by an Arduino Uno. This system switches the
power of two devices, air conditioner and
the electric heater, depending on
temperature and time. During off-peak hours, data is obtained from
the utility company. It tries to match
the electricity bill with the room temperature. A budget limit for the electricity price can
be set with potentiometer. It also attempts to turn
the air conditioner on at night and off
during working hours, six days per week. In this circuit, the
temperature is measured using lm 35 temperature sensor
and displayed on the LCD. In this complex
system, the Arduinos, which is the air
conditioner and heater, by matching the temperature, time, and power bill. Three parameters. This example should only
show what is possible with an Arduino and that even
complex systems are possible. Of course, we will start
much simpler in one of the following chapters and
learn everything step-by-step. So do not be afraid. The system can be a
stand-alone system, but it can also cooperate with Alice systems to
perform a common task. In every embedded system, there are circuits that perform the functions and send
or receive instructions. That means transmit
data in the form of voltage with the help
of conductive elements. In its simplest form, an embedded system consists of the following
core components. Processor, sensor, actuator, and an analog
to digital converter, as well as digital
to analog converter. We will look at these components in more detail in the further. Sensor is a component that can convert physical changes in the real world into an electrical signal that
can be used by a computer, ordinary electrical
system to process data. Think of it like a
human sensory organ. With the help of eyes, ears, and other sensory organs, our brain can interpret the outside world and thus
create an image of it. Similarly, you can imagine
it with computer systems. In this example, the
zeros would stand for the sense organs and the
microcontroller for the brain. The electrical signals
coming from the sensors to the microcontroller allow
the embedded system or the microcontroller
to interpret what is happening in the
outside world and then execute a response
or program given by a programmer for a
scenario by means of code. Another important component of an embedded system is the
analog to digital converter. This converts the analog signals ascend by the sensors
into a digital signal. For this purpose, as we
already know by now, binary system is used. That means the two numbers 10. These binary numbers represent the language of the system
in which a microcontroller can understand and react to difference between analog
and digital signals is, among other things,
that an analog signal can be the carrier of several
pieces of information. Whereas with a ticket
titled Signal, one can assign unique piece of information to each signal. An analog signal would therefore confused the microcontroller
to put it bluntly, processors are the heart
of any embedded system. A processor performs all tasks related to the received data. This component therefore
receives the data, stores it, processes it, and
tells the system and what way it must
react to this data. Digital to analog converter is basically just the opposite of an analog to digital converter. It converts the
digital signal sent by the microcontroller back
into an analog signal. Why is the digital signal converted back to
an analog signal? Simply because an
analog signal can be understood by physical
devices or actuators. An actuator, for example,
an electric motor, converts the analog signal received from the
microcontroller and the digital to analog converter into a
physical action. There are mechanical,
acoustic, chemical, thermal, and optical actuators that can perform physical actions
in the real world. According to that design. This is how embedded systems interact with the environment. From this, there are a
few steps that we need to take when creating or
designing an Arduino system. First, we think about what
tasks are embedded system. That means our Arduino
should perform, for example, raised appliance
when the sun rises. Then we think about which
sensors we need for this, for example, a light sensor. In addition, we need to think about the program
code for this task. Don't worry, we'll get to that. We still need an actuator
to perform the task, for example, a motor. Of course, we also have
to build the board with the components according to a previously considered circuit.
5. The Arduino Board (Hardware): In this chapter, Let's take
a look at the hardware. That means the board
of the Arduino Uno. Each pin of an Arduino board is marked with a
number or a label. The board works with five volt. In what follows, we
will look a little more closely at the
components of an Arduino, in this case, the Arduino Uno. We will now take a
closer look at some of the most important components
of the Arduino board. Step-by-step. Digital pins can supply a five voltage or 0 volt. Similarity. This can also
detect whether a voltage is present at the
pin and whether this is five volt or 0 volt. Logically, the latter is the case when there
is no voltage. We can define in our
program code whether a pin should be used
as output or input. We will see how
this works later. And internal LED is connected
to pin 13 of the Arduino. This LED can be useful
in many situations. We will do with it again later. Another LED is connected
to the power pin to indicate if the Arduino
is receiving power. The AT mega microcontroller
controls the port, controls all input and
output signals and serves as the digital control
center of the Arduino. It is the processor of
the board and later also contains the program
code transferred by the user. Five analog pins,
analog in are used to read analog voltage and
convert it to digital voltage. This is done with the help of an analog to digital converter, which we have already
learned about. The two pins, T and
D and five volt are used to supply
power to the circuits. In a project. 3.3 volt power
pin is also available. G and D stands for ground, which is the negative
terminal of the board. The board can be powered by
USB cable or power block. Arduino can work with voltages
from five to 12 volt. In no case should a higher
voltage be applied. To pins labeled TX and
RX are connected to LEDs and indicate when
communication is taking place. That means whether a signal
is being processed or not. For example, this is especially essential
for troubleshooting, which can be simplified
considerably. Finally, the Arduino can communicate with the
computer via USB port. For example, to transfer the program code
to the processor. You can reset the code at
anytime with a reset button. This button stops all functions that the port performs
and restarts it. We will neglect the
other elements and connections for now as we
will come back to them later, or in the practical project, we will understand the practical
use of the connections. In the next chapter, we turn away from
the hardware and take a look at the
Arduino software. Stay tuned after the basics, exciting and great
projects will await us. But first, a short explanation about the use of a
so-called breadboard. Breadboard is the best way to build a circuit as soon as it becomes a bit more complex
or contains several parts. With a breadboard, there is an area for the power
supply of the breadboard, plus and minus imprint. And areas with letters and numbers depends that
are in a row that tells a to E and F2 are conductively
connected to each other. This means, for example, V1 and I1 or h5 and i5 and J5
are conductively connected. The components and
cables are plucked into their respective pins and
thus connected to each other.
6. The Arduino Software (IDE) & Programming Basics: The Arduino Integrated
Development and why I meant commonly known as
the Arduino software IDE, consists of a text-based editor for writing lines of code and use section, toolbar,
several menus. The software can be connected
to a microcontroller of the Arduino board to upload
code to run a program, download the software
at arduino dot cc. In this chapter, we will
look at how to write a program code in
this Arduino IDE, which you can later execute
on the Arduino board. But first, let's take a look at an alternative method when
programming and Arduino. Before we go into
more detail about the Arduino IDE and learn how to create a
program code in it. We will first get to know the method of
block-based programming. This is simply an alternative. The more complicated
text-based programming that follows later. Block-based programming is the simplest form
of programming. This is mainly useful in great for people who
have no experience with programming because you can achieve success
quickly and easily. You can imagine it as if you put building blocks on top of
each other in the software, each of which has a
specific function. You just have to put these
building blocks together in an orderly and meaningful way
to get the finished code. For beginners, this type of programming is very
useful to learn the basics of programming
methods and general operation. The best way to get started with block-based programming of an Arduino is to use
Autodesk Tinkercad software. Tinkercad is an online platform where, among other things, you can quickly and
easily program on Arduino using the block-based
programming we just presented. After creating an account
at think a cat.com, you can get started through
block-based programming. We mainly get the following
three advantages. As a beginner, we don't
have to be afraid of small but essential errors in the syntax, the
program structure. Second, we can thus
concentrate on the main task without worrying about the programming interface. And third, we can become
more familiar with basic structure and flow of a text-based programming
through the given blocks. Code blocks are divided
into different categories. These categories are also
color-coded for patho clarity. The following categories are
available for selection. Category output. These blocks are used to instruct the
actuators what to do. Why the microcontroller, we control the output
signals through this category input with
the help of these blocks, we bring the data
from the sensors, that means the input signals
to the microcontrollers. Category notation, comments. The blocks that can be
found in this category do not directly affect
the Arduino code, but are used to indicate what the program code actually does. These blocks help the
user to understand the program code
category control. Control structures help to
enable the microcontroller to make decisions based
on the data it receives. Category variables. Variables are changing
values that the program uses to execute mathematical
functions or to store data. When we use blocks from the different categories
on Tinkercad, they align with each other
like in a flowchart. But let's just take a look at a relatively simple example. For example, we would
like to control an LED using block-based
programming and Tinkercad. In our example, we connect
an LED pin to the Arduino. Furthermore, if we put a resistor between
the negative pin of the LED and the negative
terminal of the Arduino board, G and D to control the amount of current
flowing through it. This resistor will help us
control the amount of current flowing through the LED and will prevent the LED
from burning out. For example, if we now add the first block from the
category output in Tinkercad, as shown in the image. We can use it to
turn on the LED. It also automatically implements the
following circumstances in the program code without us having to program
them separately. First, pin two is
defined as output pin. Second, pin two can no
longer be used as input pin. Third, in this code setup, the LED is connected
to pin two of the Arduino for the actual
switching on the other. Just play around
with Tinkercad and the possibility of
block-based programming, that's the best way to learn. Meanwhile, we continue with the preparation for the course, mainly discussed text-based
method of programming. In the Arduino software, you use the built-in text editor to write code for the Arduino. Code written with the Arduino
software is called Sketch. The editor includes the
following functions, among others, cut and paste
and search and replace. The message area provides the IDEs response
when code is written. Such a response can also
be an error message. For example, the
console provides text-based output
messages provided by the Arduino software. For example, general
information. Arduino code can
then be saved with the file extension
dot. When it is ready. In the lower right
corner of the window, the configured Arduino board and serial number are displayed. The toolbar buttons give you options to review
and upload programs, create sketches, open and safe, and open the serial monitor. Using the serial monitor, you can see what information the Arduino is
sending to the PC, maps the communication
between Arduino and PC. The next step, let's
familiarize ourselves in detail the elements
of the program. For this purpose,
let's take a look at the command par with icons
located in the upper part. The smaller checkmark
is to use is used to check the entered code
for errors before compiling. Compiling means that you
all the program translates the programming language into the machine language
of the computer. Compiling then starts
automatically with a click on the check mark with the error located
to the right of the checkmark and
pointing to the right. You can upload your code to
the configured Arduino board. It must be connected
via USB port. For this, with the arrows
pointing up and down, you can open or save a
sketch with the open arrow. You can also find
examples, sketches. The button next to it, which looks like a document, is used to create a new sketch. The small magnifying glass on the right side of the program
opens the serial monitor. This is used as
already mentioned, to monitor the communication
between Arduino and PC software or wise versa. Libraries represent an extension that allows us to quickly and easily give the Arduino
additional functionality. It is basically nothing
more than code that has already been written by eager
members of the community. Especially for
Arduino beginners. This is a huge help in
terms of time and effort. You can use a library
by importing it. This is done in the
Arduino software IDE in the menu at the top
under the item sketch. Here, you select Include Library and then select the
library you want to use. You will get hashtag include statements at the
beginning of the code. Alternatively, you
can just write them directly at the
beginning of the code. If you know the name
of the library, the library manager is used to install new libraries
in this sketch. To do this, open the program IDE and click on
the sketch menu, and then on Include Library, and then select
Manage Libraries. The library manager,
we find a list of libraries ready
for installation. Now, we want search,
for example, for the DMU library. To achieve this, we simply
type in the abbreviation IMU. In the search field. After that, we can select
the version of the library. Imu is the abbreviation of inertial measurement
unit and is the name for a measurement unit
sensor network that is used to measure acceleration
and rotation rates. After we have selected
the latest version, we can click on the Install
button and then have to wait briefly for the new
library to be installed. If we switch to the Include
Library menu item again, we can check whether
the library is now present and the installation
was successful. New or needed. Libraries can also
be found online. These can be downloaded and installed as compressed files. Most libraries can be found
on GitHub, github.com. Github is a Management
Platform community for software development. Once you have
downloaded the library, you can load it into the
program in the following way. In the Arduino
IDE, go to Sketch, Include Library, then
select Add SIP library. Then we are prompted to specify the location of the
decided Library. Navigate to the location of the downloaded file,
and select it. I will tell you which
libraries we need for our subsequent projects at the
beginning of each project. If we then click again on the sketch tab in
the upper menu bar, and then on Include Library. We can, if the process
was successful, see the installed library in the lower area of
the dropdown menu. Now the library is
ready to be used. The serial monitor
is used to display data sent from the
Arduino to the computer. Here it is important to
select the correct baud rate. Select the baud
rate bottom-right, so that it matches
the rate defined in the sketch environment
at Serial.begin. What this means exactly. You will understand
better when we get to the practical projects. It's best to go on first if you don't understand
something right away. By the end of the course, it should be clear that we do not have to work exclusively with
block-based programming. We would like to get to know text-based Arduino programming
in this chapter as well. This type of programming is
a bit more difficult because we need to know the exact
syntax and functions. Arduino code is written in C plus plus
programming language. Therefore, this
chapter will give a basic overview of the structure of a
text-based Arduino code, as well as introduce the most important functions
while US and structures. After working through
this chapter, we also already gets to the
very practical programming and implementation of some
great arduino projects. We've read the code
and the Arduino IDE in the text-based editor
in a so-called sketch. This contains the complete code which is then transferred to the Arduino microcontroller with the Upload button right arrow. Before that, you have to click the check mark to
compile the code. For any code written
for an Arduino, there are two
essential components. The first of these is
set up the code inside the following curly braces of this function is
executed only once. And all relevant and
essential information and structures for further
code are listed here. For example, we tell them
microcontroller here, which pins are used as inputs and which pins are
used as outputs. The other essential
component is loop. The loop function
creates a loop. This means that the code inside the following curly brackets. Will be executed
again and again. And not only wants any task that the microcontroller is to
perform is written into here. The basic code is
written in here. Let's first familiarize
ourselves with the general program
structure or syntax. When programming Arduino code. You can mention the syntax like the punctuation marks and
paragraphs in the text. For example, after a
sentence, you make a period. But when programming in Arduino, you make a semicolon
after each line of code. In addition, we must adhere
to the following structure. Curly braces are used to
start and stop a function. When the function is executed, the code inside these
parentheses is executed. Semicolon tells the code that the current line
of code is finished. Two slashes are used
to write a comment to better understand as a human
what the code is doing. All lines of code
that start with these characters are ignored
by the microcontroller. Multi-line comment can also be started with a slash
followed by an asterisk. When you are done with this, you set the string
in the opposite way. That means first and
Asterix and then a slash. All lines of code between these characters
are also ignored. The microcontroller. With hashtag define, you can assign a name
to a constant variable. With hashtag include, you can include an external
library into the code. If a code should
not work once the software gifts an
error when compiling, you should always check
first whether you have used all syntax
elements correctly. For example, check
whether there is a semicolon after
each line of code, or whether all comments
start with two slashes, or whether all the
necessary brackets open and closed, F been set. The following operators
are used when programming in code to define
logical comments. When the following
operators are used in programming to define logical comments when
programming are doing new code. Two equal signs mean
equality of two variables. For example, x equals equals y, x and y both equal. Commission mark followed by
an equal sign means unequal. A less than sign means less
than another variable. A greater than sign means
greater than another variable. Unless equal sign means less than or equal to
another variable. Greater equal sign means greater than or equal to
another variable. With a percent sign, you can get the remainder. Mathematical operation. An asterix is used
for multiplication, plus is used for addition, minus is used for subtraction. Slash is used for the division. Equal sign is used
to assign a value to a variable to end signs are operator for logical end to vertical science are the
operator for logical OR plus. Plus means add one
to a variable. Minus minus means subtracts
one from a variable. Plus equals is the
abbreviation For x equals x plus y minus equals, for example, is the abbreviation
for x equals x minus y contains multiple
values for one variable. Boolean stores the binary state of a variable, true or false. Byte stores a byte value. Char stores one character. Float stores a four-byte
value in decimal form. Double stores an
eight byte value, also in decimal form, int stores a four-byte number long stores in
eight byte number. Size t stores the size
of a variable in bytes. String stores a text unsigned, followed by, for
example, int or long, or other command helps with negative numbers and unsigned
consideration is performed. Void is used for function
declarations that do not return a value at
the end of the function. When programming for an Arduino, data or values can be either
a constant or a variable. Here is the
difference constants. A constant is a fixed value, that means a data
element to which a value has been
permanently assigned. The constant high means that the microcontroller should
apply five volts to a PIN. Additionally, which
one has to be defined? The constant low,
on the other hand, means that Arduino should
apply 0 volts to a pin. In addition, which one
has to be defined. The term true is used to define that a certain
statement is true. The term falls is used to define the particular
statement is false. Input defines that the pin to be determined is used
for an input signal. That means that the
microcontroller should read which voltage
is present at this pin. Output defines
that the pin to be determined is used
for an output signal. That means that the
microcontroller should apply either 0 or a five volts
high or low to this pin. Input pull-up is used to connect an internal
resistor to a pin. Led builtin is used to control
an LED connected to pin 13 of the Arduino describes
a fixed numeric value. Variable is a data element
in the Arduino program that associates a name or letter within
the assigned value. Defining a variable is
called declaring a variable. In the programming language, you can perform all kinds of mathematical operations
with a variable. For example, using
this line of code, we declare an integer
variable that is named x has a value of 45. When we have declared the
variable in this way, we can use this variable
in our program. Such a declaration must
always take place first. Otherwise, the
microcontroller will not know the variable. Now, we can calculate
with this variable, for example, at the value
ten to this variable. This would then look like this. This line of code says that
the new value for x is equal to the old value of
x plus the constant ten. We can also transfer the value from one
variable to another. We do this by writing
the new variable on the left side and the original variable
on the right side. For example, we want to store the value of x in
a new variable, for example, in the variable y. Then we have to write, once a variable is declared, it is associated with the stored value
throughout the program. If we try to assign this
name to another datatype, the IDE will give
an error message. Also essential is the scope
of the declared variable. This simply means that if we declare a variable at the
beginning of the program, we can use it anywhere
in the program. However, if we declare a variable only in a
specific function, then the variable can be
used only in that function. The following code, we can declare three variables
for this purpose as an example and consider what the scope
of these variables is. Now we have declared three
variables named x, y, and set. What about the scope? X is a global variable
and can be used in any of the functions declared at the beginning of
the program code. Why was declared in the
scope of void loop. So it can only be
used in that scope. And set was declared
void new function. So again, it can only be used
in that specific function. So always pay attention to which variables you declare
in which place. To combine the
individual variables, operators and constants into a function or a
working structure. We need expressions that
create the control or command. The most important
ones are as follows. If is used for checking a
condition and is used to perform an operation when
that condition is met, else is used for the action to be performed if the
condition is not met as if is used when a second
condition is to be checked. If the first
condition is not met, break stops the code in a loop, continue, restarts the code in the loop while it's used to create a small
loop within the code. This is executed until a
defined condition is met. For it's used to
create a loop that is executed with defined
number of operations. While is used to create a small loop that runs
until a condition is met. Go-to makes the program
continue in a certain line. Return will return
a specific value at the end of the function. Functions are basically nothing more than a abbreviations for a code segment that
you would actually have to write again and
again for a certain action. Since some actions are
needed frequently, it makes sense to bundle
them in certain expressions. The functions, functions are simply dictate like variables. In addition, functions brings
some other advantages. Some advantages that
functions offer are the code remains
organized and structured. Debugging the code
becomes straightforward. That is, if the
code doesn't work, the code is efficient and clear. The code is straightforward
to understand for a new user. As an example, we can create a function that
adds two numbers. In this code, we have declared a function called test function. At the beginning, we
use the word void, which means that the function
does not return a value, but only performs the
action that means at x and y and then
stores them in set. If we want to output
the value for set, we need to construct the
function as follows. This function is of the
integral data type. It adds x and y, then stores the result, that means the value in set and then outputs
the value of set, which is stored in an
integer variable called a. We have started the functions in both cases in the
void loop area. We did this because we want the function to be
executed continuously. That means in a loop. If we wanted to
execute the function only once at the
beginning of the program, we would have put it in
the void setup scope. Some very basic and important, as well as already declared and thus ready to use functions utilized in Arduino
programming our digital read, to read a digital input, digital the right to write to a digital output pinMode
to assign an order, make a pin connector
of the board, either an input
or an output pin. Analog read, to read
the analog input. And I'll look right to
write to an analog output. Stop every tone of a
passer with no tone. To start a tone in the buzzer, we use tone to read
a pulse on a pin. We use pulls in. Pulls in long is used
to read long pauses. To shift the byte of data. We use either shift in or shift out random to find a random
number within the bounds. To make the program wait for a certain time, we use delay. The number we put in
the brackets then describes the waiting
time in milliseconds. That for example,
delay 10000 means code weights 1000
milliseconds equals 1 second. To make the program
written microseconds, we use delay microseconds to read the time that has passed since the program was started. Micros, microseconds and
millions in milliseconds. To get the absolute
value of a number, we use apps to
specify constraints. We use constraint to find
the maximum of two numbers. We use Macs to find the
minimum of two numbers. We use min to calculate
the power of a number. We use power to find
the square of a number. We use square. To find the square
root of a number, we use square root. To calculate the value of a bit. We use pit to set a
specific PID to 0. We use bit clear to read a
single pit from a number. We use Pitt read to
set a bit to one. We use bit set to convert
a number into bits. We use pit right to get the
leftmost byte of a number. We use high byte to get the bite on the
far-right of a number, we use low byte to attach an external interrupt
function to a pin. Views attachInterrupt to remove an external interrupt
function from a specific pin, we use detached interrupt to start the internal
interrupts views interrupts, and to stop the, stop them, we use no interrupts. Byte is used to convert
a value to a byte. Char is used to
convert the value to a character variable. Float is used to convert a
value to a float variable. Int is used to convert a value
into an integral variable. Long is used to convert a
value to a long variable, and string is used to convert
a value into a string. In the following, we will
learn how to use some of these functions using
example projects. So don't worry if you don't know specifically how to
use the functions, operators, and conditions yet. Before we get to the project, let's take a brief look at
how to connect the board to the PC and load
some program code onto the Arduino port to connect the Arduino board with the PC or the Arduino IDE software. We first have to connect the Arduino port with
a USB cable to the PC. Then we open the menu tools in the Arduino IDE in the menu bar and select
the correct port type. In our case, the Arduino
Uno in the menu board. The next step we have
to make sure that the correct use P port
of the PC is assigned. We can also determine this on the tools and the port sub menu. This menu item can be found
directly below board. Here, the port must be selected, which has Arduino or a
similar designation, for example, also generally know the Arduino is connected
to this port on your PC. Now, the Arduino
board is probably connected to the PC or software. And we can start by writing
the first program code, compiling it, and
loading it on the board. We do this as follows. First, we write the
program code or copy it into the text
editor of the IDE. If you have a program code
already complete in itself, just delete the already
exists in syntax in the IDE. Then save the sketch. Then we press the
smaller checkmark to check and compile the code. If no errors were found, the message appears that the compilation was
completed successfully. This may take some time
depending on the code length. Finally, we load the code onto the Arduino port by pressing the arrow pointing to the right. Then the Arduino will start
executing the program code. Before that, you can open
the serial monitor to monitor the communication
between board and software.
7. Project 1: A flashing LED and an SOS signal: Project one, a flashing
LED and an SOS signal. In this project, we will control the state of our LED light. For this, we will use an
Arduino Uno to switch the LED on and off with
a delay of, for example, three seconds duration
of the LED's glow, or five seconds switched off
state required components, one Arduino Uno, one
breadboard for jumper wires, one LED, 1200 ohm resistor. We connect the LED to the
Arduino using a resistor, the cables and the
fret board, as shown. For this, we first apply
the breadboard with power. We connect red cable to the five volt pin of
the Arduino board. And the other end of the cable, we pluck into the bread board
as shown in the picture. We also connect
the black cable to the G and D pin of
the Arduino board. And the other end of the cable, we pluck into the breadboard
as shown in the picture. Then we place the LED, short-term lack of the
LED to the resistor. The resistor as shown, and connect the LED with a black wire to the
ground of the board. We need the resistor
to limit the current. Here. We use Ohm's law
and the formula r equals u divided by I. R
stands for the resistance, you for the voltage
and I for the current. Finally, we need a yellow cable. Can also be another
color which goes from the LED to the board pin to program code for
the Arduino IDE, we first declare the variable
LED pin and assign it to the pin to which we have
connected the LED pin two. Here we enter the setup code
to be executed only once. We want the LED pin to be
defined as an output pin. That means to receive an output signal that
the LED lights up. That means, here we enter the main code to
be executed in a loop. First supply LED pin with
five volt switches LED on. Then wait, 3 thousand
milliseconds, three seconds. Then supply LED pin with
0 volt, turns LED off. Then wait 5 thousand
milliseconds, five seconds. The loop then executes
the program code rapidly. That means the LED rapidly
switches off and on with the previously defined
delay of the program code. As an exercise, try
switching the LED on and off at this point that
an SOS signal is sent. Sos signal three times
short, three times long, three times throught
long signal, two seconds short
signal, 1 second. Distance between short and long, 0.5 seconds, distance of five seconds between
several SOS signals. Pause the video for a moment at this point and try it yourself. The solution will
follow shortly. Now the solution follows. We only have to
change the part in void loop in the
previous program code. For the SOS signal, this could look like this. A short signal is defined
in the following. For example, with 1 second
along one with two seconds LED on between the signals, there should be 0.5 seconds
for this connection, LED of the three short
signals follow first. First supply the LED pin with
five volt switches LED on. Wait for short
signal, one hundred, ten hundred
milliseconds, 1 second. Then supply LED pin with 0
volt switches LAD of weight, for example, 500 milliseconds
to separate 0.5 seconds. Supply LED pin with a five volt. Again, switches LED on. Wait for short signal 1000
milliseconds, 1 second. Then supply LED pin with
0 volt switches LED off. Wait for separation.
For example, 500 milliseconds, 0.5 seconds. Supply LED pin with five volt. Again, switches LED on. Wait for short signal on
1000 milliseconds 1 second. Then supply LED pin with
0 volt switches LED off. Wait for separation,
for example, 500 milliseconds, 0.5 seconds. Then the three long
signals follow. First supply LED pin with
five volt switches, LED on. Wait for long signal 2 thousand
milliseconds to seconds. Then supply LED pin with
0 volt switches LED off. White, for example,
500 milliseconds for separation, 0.5 seconds. We need this paragraph
two times more. Finally, three short
signals follow, just like in the first section, to separate between
several SOS signals. For example, weight 5 thousand milliseconds,
five seconds. The loop function then executes the SOS signal rapidly
and permanently. When you try the code, don't forget the rest
of the code structure, as in the first project. Just replace the part inside void loop from the first project
with the code from here. Excellent. We have successfully
completed the first project. Let's move on to
a second project. This one will be a
bit more difficult.
8. Project 2: Temperature based LED light: In this project, we will
control the state of an RGB LED based on
the temperature. While you detect it by
a temperature sensor, the temperature is high, the light should turn red. On the other hand, when
the temperature is low, the LED should turn blue. When the temperature is optimal, the light shall be green. Required components, one
Arduino, one breadboard, jumper wires, one RGB LED, 1200 ohm resistor, one LM
35 temperatures enter. The LM 35 provides an analog
output voltage that is linearly proportional to the temperature in
degrees Celsius. The temperature
range is from minus 52 plus 155 degrees Celsius. Convert the analog voltage
into a temperature. A scaling factor
of ten millivolts per degree Celsius is required. The assignment of output voltage and temperature in Celsius, it can be read from
a linear function. For example, 500
millivolt signal of the sensor corresponds
to 50 degrees Celsius. And RGB LED can shine
in three colors, namely red, green, and blue. The LED has two more
connections than a normal LED, and the color of
the light depends on which connection is
supplied with current. To control the LED, you need pins 365, which are actually
digital pins that also allow pulse
width modulation. You can recognize this
by small printed wave. Also at pin 91011. First we supply the
breadboard with power again. For this, we connect
the red cable to the five volt pin of
the Arduino board. And the other end of
the cable we block into the breadboard as
shown on the picture. In addition, we
connect black cable to the GND pin of the Arduino board and the
other end of the cable. We also plug into the breadboard
as shown in the picture. Then we add the RGB LED and
the temperature sensor TMP. Make sure that each leg is correctly seated
in the connectors. You need to be careful
here not to break any of the legs when bending
them into place. The two outer legs of the
temperature sensor was applied with Power BI connecting
a black and a red wire. The plus and minus pole of the breadboard connect
the middle leg of the temperature sensor
with a colored cable to the connector of the Arduino. We connect the legs of the RGB
LED with colored cables to the digital pins 356
of the Arduino board. Furthermore, we need a
resistor to connect one leg of the RGB LED to the negative
pole of the breadboard and thus also to the t and depot of the Arduino program code
for the Arduino IDE. We first declare our variables by assigning them to the
respective connection pin. The abbreviations are B, D, T stands for red, blue, green and temperature
respectively. Connection for red
glow of the LED pin. Connection for blue glow of LED pin connection for
green glow of LED pin six. Temperature sensor
is connected to pin. Here we entered a setup code
to be executed only once. We want all pins connected to the LED to be defined
as output pins and the pin connected to the temperature sensor
to defined as input pin. First we need the
above command for the serial interface data
rate 9,600 per seconds. This starts the communication between PC and Arduino board. And the temperature is
transmitted to the serial monitor in the IDE baud rate 9,600. Definition of pin R, that means P3s output pin, definition of the pin B. That means the pin
A5 as output pin, definition of pin G. That means pin six
as output pin. Definition of Penn t, that means pin 0 as input pin. Here we enter the
main code to be executed repeatedly in a loop. First, we defined with
the following code, the function temp, which
we will need in a moment. For this purpose, the microcontroller
is to read the value in our LM 35 is an analog
temperature sensor. Shows us the temperature in the serial monitor.
The following. We create an if and several S
If conditions which control the LED in several steps depending on the
temperature of the sensor. Therefore, we use analogWrite instead of digital right here, only 0 volts or five
volts would be possible. See first project. When the output voltage rises above the
value 300 millivolt, approximately 30
degrees Celsius, according to the scaling factor, the following values should
be applied to the pins. Strong red color, while use
gradeable from 0 to 255. If the voltage is above the
value of 250 millivolts, approximately 25
degrees Celsius. On the other hand,
the following values should be applied to the pins. The following, analogously,
a medium red color, faint red color,
strong green color, mixture of blue and
green, strong blue color. The loop then executes the
program code repeatedly. That means the temperature is measured and interpret
it continuously and the signal is passed to the energy of the program code.
9. Project 3: Light-dependent control of a motor (blind motor): In this project, we want to control the blinds of a window with the help of a server
motor and an LDR sensor. This should happen depending on the amount of light
coming in from outside. Required components. One Arduino Uno, one breadboard, one photoresistor, LDR
sensor, one cerebral motor. Nine chump Hawaii
has one resistor, 4.7 kilo ohm. Names or chests. Photoresistor can be thought of as a simple resistor that has the special feature of changing its resistance value depending on the amount of incident light. The last slide falling
on the sensor. The higher the
resistance becomes, the more light falling
on the sensor, the lower the
resistance becomes. The sensor is based on
the photoelectric effect. As usual, we first supply
the breadboard with power. To do this, connect
the black and the red cable from
the GND pin and the five volt pin of
the Arduino board to the positive and negative
pole of the breadboard. By the way, it doesn't matter which GND pin of
the board is used. Then we insert the photoresistor
and the servo motor, as shown in the picture. There is still one resistor
missing and the rest of the wiring you can do as
shown in the picture. Program code for
the Arduino IDE. First, we include
the required library for the several motor
in our program code. If the IDE gifts an error
message when compiling, you must first install this
library, the library manager. Then we create the
several object so that we can control
the servo motor. Then we declare the
connection pins for cerebral motor and
sensory photoresistor. Then we have to declare
variables for the position of the several and for the properties of
the photoresistor. Very able for saving the several position variable to store the several
position at max slide. This is the value we defined as maximum light incident light
intensity at any position. Here we enter a setup code
to be executed only once. Here we want to connect
the cerebral with the several object and start
the serial communication. Connects the cerebral to pin
five with several object. Starts serial communication
set baud rate to the serial monitor is
defined as input pin. Here we enter the
main code to be executed repeatedly in a loop. For each position from 0 to 180 degrees of the several motor execute the following code. Pos plus equals one means
pus equals plus one. That means pus equals
0 plus one equals one. Set position of several motor
and read send your values. Set position for several
0 to 180 degrees. Read sensor value and
overwrite variable. Check if maximum light
incident is reached. If this condition is true, it means that the
output value for the variable max slight equals 997 is greater than the value that the sensor
is currently outputting. That means the
maximum brightness would not have been reached. Store new value for
maximum brightness. Save the several position. Shows us the intensity
in the serial monitor. Weights 50 milliseconds until the cerebral motor has
reached the position. Read sensor value, light
incidence also in reverse loop. Position from 180
degrees to 0 degrees. Store new value for
maximum brightness. Save the several position
at maximum light incidence. The following section,
the several is to move to the position that was saved if the following
condition is met. Check if the noun new store
value of the variable is not equal to the initial value of the variable darker
than maximum light. Go to define position of
maximum light incidence. Shows us the sense of value
in the serial monitor. Weight 20 seconds. Check whether the light
intensity has changed or not. Float equals floating
point numbers. Checking the change of
the light intensity. Wait three seconds. Reset initial variables. End of the program code.
10. Project 4: Gas detection alarm: We will build a gas detector
that will sound an alarm. If it detects a gas leak, the alarm will sound until
the gas leak is stopped. In addition, LEDs are
triggered depending on the amount of gas
that the sensor detects. If there is a lot
of gas leaking, all four LEDs should light up. If there is little gas, only one of the four
LED should light up. Required components. One Arduino Uno, one breadboard, one gas sensor, one bossa, 14 jumper wires, five resistors, one kiloohm
for LED and gas sensor. One resistor, a
100 ohm for bossa. For LED. We connect all the
components and the Arduino together
on a breadboard, as shown on the picture. Make sure that you
use the correct pins. Who can also arrange the components
differently if you like. However, the circuit
should remain comparable. But then you might
have to change the variables or names
in the following code, program code for
the Arduino IDE. We first declare
our variable for the gas sensor by assigning
the connector pin. Here, we enter the setup code
to be executed only once. We want pin a 0, which is connected to the gas sensor to be
defined as input pin. Also, we want all pins
connected to the basilar or LEDs to be defined
as output pin. Define gas sensor pin as input. Defined bust a pin as output. Define LED pin as output. Then we stop the communication
with the serial interface. Data rate, 9,600 bits per seconds with
the following code. This starts the communication between Arduino port and PC, and the data is transferred to the serial monitor in the DE. Here we enter the main code
to be executed repeatedly. First we declare a variable
that should read the sensor. Then we generate the
tone at pin seven with 220 hertz for
100 milliseconds, tone is activated as soon as the center resistors
measured value, that means gas no matter
in which quantity. Then wait 200 milliseconds. Then no tone should be
applied to pin seven anymore. Then 1010 thousandths
milliseconds should be weighted for the following, we create an if and several S
If conditions which give us different control of the LEDs depending on the gas value
measured by the sensor. We use digital right here. If value is greater than 75, then switch on all LEDs. Otherwise, if between 5075, then switch on only three LEDs. Otherwise if between 2550, then switch on only two LEDs. Otherwise, if between 025, then switch on only one
LED off the program code.
11. Project 5: Password protected mechanical system: In this project, we will create the system that is
protected by a password. It will remain locked until the user enters the
correct password. When the correct
password is entered, the cerebral motor will
move and open the system. We will assign different
passwords to different uses. Each user will have their
own user ID and password. The system will
only be unlocked if these two security features
match and are correct. Moreover, after multiple
incorrect entries, the red LED buzzer shall be activated and the entry shall
be locked for 30 seconds. On the other hand, if the input is correct, the green LED should
be activated. Required components. One Arduino, one breadboard, one key pet, one LCD display, various jumper wires,
three resistors to LED buzzer, one cerebral motor. We link all the components and the Arduino together
as shown in the image. We don't use a breadboard
this time because almost all the
connections are between the Arduino and the
individual components anyway. But you can also use a breadboard for
this if you want to. Before we start with
the program code, we have to install the required
library for the key pet. The pet by Mark Stanley
and Alexander Breivik. We do this either via the
library manager or research the corresponding zip file online using Google and find it, for example, here, playground dot arduino dot cc and load it into
the Arduino IDE. You may need to do this
for the display as well. Program code for
the Arduino IDE. First, we include the
necessary libraries for the server motor, the keypad, and the LCD
display in our program code. Then we create a server object so that we can control
the cerebral motor. The following, we declare our variables for the
green and red LED, as well as for the buzzer by assigning the
connector pins 101213. We then declare the
number of rows and columns of our keyboard
field. For each. With key map, we define the keys on the key
pet that can be pressed according to the row and columns as they appear
on the keyboard. Then we need code that maps the connectors of the keypad
with the connectors on the Arduino grows 0 to
three columns, 0 to three. The following code initializes an instance of the keypad class. The following code
creates a variable for the LCD display with the numbers of the
pin interfaces assigned to the LCD display. The following. We assign
the user IDs and passwords. In addition, we declared
the following variables. Here we enter the setup code
to be executed only once. Start serial communication. Initialize LCD display. Wait 500 milliseconds. Define green LED
variable as output. Define a red LED
variable as output. Defined buzzer as output. Set the position of the text
on the display, column, row. Show text. Enter the code. Set the position of the text
on the display column, row. Display text to open lock. Now we need code for
the server motor. Servo motor is
connected to pin 11. Cerebral motor should move
to position five degrees. Wait 1500 milliseconds of
the code for void setup. Here we enter the main code
to be executed repeatedly. Below is the coat that verifies the entered user
ID and password. The following message should
be shown on the display. If the password was
entered incorrectly. Set position of the following
text. Display text. Position of the following
text. Display text. Wait three seconds. Allow input to start again. Set position of the following
text. Display text. Set position of the
following text display text. Weight 0.5 seconds. Start verification from scratch. If the ID check was correct, but the password
was not or not yet. The following should
be displayed. Set position of the following
text, display text. Set position of the following
text, display text. The ID check was correct and the password check
was also correct. The following should happen. Following is the code
that will be executed if the password and ID
are entered correctly. Green LED should light up. Set position of following
text, display text. Set position of the following
texts. Display Text. Wait five seconds. Set position of the following
texts. Display Text. Set position of the
following text. Servomotor opens 180
degree movement. 1.5 seconds. If the wrong input is
made several times, the input should be locked for thirty-seconds and the red LED, as well as the pastor,
should be activated. The following is the code for this Set position of the
following text. Display text. Set position of the following
texts, display text. Red LED should light up. Pasa should be activated. Subsequently wait 30
seconds and Display Text. Set position of the following
text to split text. Display number of seconds
remaining. Display text. Switch off, a red
LED. Switch off. Set position of the following
text, displayed text. Position of the following text, display text of
the program code.
12. Project 6: Remote controlled unlocking mechanism: In this project, we will control a mechanism for opening and closing a gate with
an IR remote control. To be able to open the gate, the code should be entered
on the remote control. For example, 16580863. In addition to RGB LEDs and the buzzer shall
accompany the process. Furthermore, temperature
sensor should monitor the ambient
temperature and issue an error message if the
temperature is too high. Additionally, an LED
shall be activated if the photo sensor measures
only little ambient light. Furthermore, we install a pattern switch for
manual operation. Required components,
one Arduino Uno, breadboards, one, IR
infrared remote control, one IR infrared receiver sensor, one LCD display, various
jumper wires, six resistors, one potentiometer, one bossa, one several motor to
RGB LEDs, one DC motor, one L2 nine 3D motor driver, one LDR center, photoresistor, one temperature sensor,
one button switch. Connect all components as shown. Before we start with
the program code, we have to install
the required library for the IR infrared
remote control. I are remote by arming
your Kim's Meyer. The best way to
do this is to use the library manager search for the library in the
IDE and load it. You may have to do this
for the display as well. Program code for
the Arduino IDE. First, we include the
necessary libraries for the server motor, the IR remote control, and the LCD display
in our program code. The following. We first declare
the variable for the IR sensor by assigning
the connector pin A2. We also need the
following two expressions for the IR sensor. Then we create again
several object so that we can also
control the server moto. The following code creates a
variable for the LCD display with the numbers of
the pin interfaces assigned to the LCD display. Below, we define
the function for opening tone at pin eight with 220 hertz
for 100 milliseconds. The server motor should
move to position 0 degrees. Wait 15 milliseconds. Declare variable temp, read temperature while you as long as the temperature
is above 25025 degrees, since ten millivolt,
ten millivolts equals one degree
Celsius, shawl. Activate LED, pin 13, disabled LED, pin four. Set position of the
following text, show text. Set position of the following
text. Display text. Read temperature value. Activate LED. Pin A4. Deactivate LED pin 13. Activate pin seven, motor. Deactivate pin eight motor. Wait three seconds. Set position of the following
text, display text. Deactivate pin seven. Enabled pin eight. Wait two seconds. Deactivate pin seven
enabled pin eight. Wait 100 milliseconds. The several motor should move
into position 90 degrees. Wait 15 milliseconds.
The following. We define the
function for the LED. When there is too little light. Declare a variable
light, red light value. Light quantities over 500, then deactivate pin ten. Set position of the
following text. This split text. Flat quantities under 500, then activate pin ten. Set position of the following
texts, display text. Here we enter the setup code
to be executed only once. Initialize LCD display columns, rows of the display. Stop the IR sensor with
the following code. The several motor is
connected to pin six. The server motor should move
in position 90 degrees. Wait 15 milliseconds. Activate LED at pin a for
deactivate LED pin 13. We enter the main code to
be executed repeatedly. Terminal A5 gets current
five volt because high. Then set position of the
following texts show text. Execute the open function. Set position of the
following texts showed text. The following code
says the following. If a signal was given by the IR remote control or
received via the IR sensor. If the signal corresponds
to the following code, 16580863 was an IR signal. The received signal match code. Set position of the
following texts. Show text. Execute the open function. Received next value. Set position of the
following text, Show Text. Wait 100 milliseconds of code.
13. Closing words: Excellent, You've done it. You've worked through
the beginner course. Congratulations. This course, I've tried
to bring you closer to the basic knowledge
for the use of an Arduino with
simple explanations. I hope that I have succeeded to some extent and that
this course has prepared you well understandable
and practical introduction to the world of the mini PC. And you now understand
why the Arduino is such a great system and
what you can do with it. The aim of this course was to give you an understanding of how electrical engineering
accompanies as in everyday life and the
basic principles involved. It should be a
course that creates an understanding of the
theoretical background, knowledge, and
practical application. With this basic course, you should now know
everything you need to know to use an Arduino
as a beginner. Of course, it makes sense
not to stop at this point. And the rather look into an
advanced course to learn even more about creating
systems using an Arduino. Together we have accomplished
quite a bit in this course. Be justifiably proud of yourself if you
made it to the end. If you like this course, I would be pleased if you
leave me a rating and a short feedback as well
as recommend the course. Thank you very, very much. One final tip. If you ever get stuck, take a look at the following
site where you will find many and great learning
materials about the Arduino. Arduino dot cc. If you're also interested in other courses on similar
technical topics, feel free to visit my
profile and be sure to take a look at the other
courses I am teaching. Thank you very much. See you.