You are on page 1of 38

MINISTRY OF EDUCATION AND SCIENCE OF UKRAINE

NATIONAL UNIVERSITY “ZAPORIZHZHIA POLYTECHNIC”

Software Tools Department

Guidelines&Templates
for laboratory works
on the course
"ES as the basis of IoT infrastructure"

2023
2

SET OF LABORATORY WORKS


TO TRAIN DESIGN AND TECHNOLOGICAL SKILLS FOR IOT
SYSTEMS PROTOTYPING USING ONLINE ENGINEERING TOOLS

TABLE OF CONTENT
Laboratory work №1 Getting started with Tinkercad ....................................... 3
Laboratory work №2 Ultrasonic distance sensor and servomotors................... 9
Laboratory work №3 RGB LED and smoke detector ..................................... 15
Laboratory work №4 Photoresistor ................................................................. 21
Laboratory work №5 Motion sensor ............................................................... 24
Laboratory work №6 Temperature sensor ...................................................... 28
Laboratory work №7 Group of sensors........................................................... 32
Sources of useful information ......................................................................... 38
3

Laboratory work №1
Getting started with Tinkercad

Goal: get started with Tinkercad, learn to create circuits using


Arduino.

1.1 Overview of Tinkercad

Tinkercad – is a free web application that allows creating 3D


models, circuits, programs using codeblocks and AR objects.
First you need to create an account. To do this, open main page
tinkercad.com and choose “JOIN NOW” (Fig. 1.1).

Figure 1.1 – Tinkercad main page

After creating an account, a page with projects will open, where you
need to open the tab "Circuits" (Fig.1.2). Here you can review your circuits.
After that you need to push “Create new circuit” button (Fig. 1.3).
Circuit editing page consists of working area, toolbar and
components catalog (Fig. 1.4).
4

Figure 1.2 – Account main page

Figure 1.3 – "Circuits" tab

Figure 1.4 – Circuit editing page


5

Toolbar has following commands (left to right):


• Rotate component;
• Remove component;
• Undo;
• Redo;
• Add comment;
• Show/hide comments;
• Choose wire color;
• Choose wire connection type;
• Open code panel;
• Start simulation;
• Save circuit.

For adding component to working area, choose it in catalog and drag


drop to working area.
Let’s create simple project. Drag and drop "Arduino Uno R3",
"Breadboard small", six LEDs and six resistors. Connect them as it shown in
Fig. 1.5. You can change wire color by selecting it and choosing desired color
in toolbar.

Figure 1.5 – Assembled circuit

Then you need to program the circuit. To do this, choose "Code" in


toolbar and then choose "Text" option in drop-list. Then code editor will open
where you can write code (Fig. 1.6).
6

Figure 1.6 – Coding window

Below is an example code that we are going to use:


void setup()
{
for(int i = 0; i < 6; i++)
pinMode(i+2, OUTPUT);
}

void loop()
{
for(int i = 0; i < 6; i++)
{
digitalWrite(i+2, HIGH);
delay(300);
digitalWrite(i+2, LOW);
delay(300);
}
for(int i = 4; i > 0; i--)
{
digitalWrite(i+2, HIGH);
delay(300);
digitalWrite(i+2, LOW);
delay(300);
}
}

Put this code in the editor and click "Start Simulation". If everything
is alright, LEDs will light up one by one (Fig. 1.7).
7

Figure 1.7 – Beginning of simulation

Then change circuit name and save it in brd format (Fig. 1.8).

Figure 1.8 – Circuit saving

Brd file can be downloaded on computer. You can also review your
circuit in your profile on "Circuits" tab.
Lets create another project with digital button. Drag and drop
"Arduino Uno R3", "Breadboard small", one button and one resistor (10kOm).
Connect them as it shown in Fig. 1.9.
Write the code from the Fig. 1.9 and click "Start Simulation".
Open the Serial Monitor that is located in the bottom of the “Code”
sidebar (Fig. 1.9). Press the button and see what happens when button is
pressed and not pressed.
8

Figure 1.9 – Simulation with Serial Monitor

1.2 Work assignment

1.2.1 Review Tinkercad environment.


1.2.2 Create and program circuit as in the example.
1.2.3 Create circuit "Traffic light for car". Three LEDs (red, yellow,
green) light up in the following order: red turns on → yellow turns on → red
and yellow turn off, green turns on. Time between LEDs is 1 second.
1.2.4 Add to the “Traffic light for car” a traffic light for the
pedestrians (2 LEDs with different colors (green and red)) and a pushbutton to
mimic the ones in the pedestrians’ traffic lights.

1.3 Content of the report

1.3.1 Topic and goal of work.


1.3.2 Screenshots and code of created projects.
1.3.3 Conclusions.
9

Laboratory work №2
Ultrasonic distance sensor and servomotors

Goal: get started with ultrasonic distance sensor and servomotors,


learn to create Arduino circuits using these components in Tinkecad.

2.1 Brief theory

Ultrasonic distance sensor (Fig. 2.1) is a miniature device that can


measure the distance to an obstacle.
This device is a board that consists of the ultrasonic emitter, receiver
and electronic circuit. The sensor is small in size has and a simple interface:
two power outputs (VCC and GND), input and output for data transmission
between the controller and the module [1].
Emitter transmits a short ultrasonic pulse, which is reflected from the
object and received by the sensor. Distance is calculated based on time to
receive the echo and the speed of sound in the air. The receiver receives an
echo signal, and outputs the distance encoded by duration of the electrical
signal at sensor output. The next pulse can be emitted only after the echo
disappears from the previous one. This time is called cycle period [1].
Sensor can be used to detect a presence of human in a smart home or
security system, as well as for various robotic systems. In addition, using this
module, you can make a parktronic for your car [1].
Servomotor (Fig. 2.2) is an electric motor with a control unit, which
due to signal can accurately maintain a given position of the shaft or a
constant speed [2].
Servomotors are used to gently actuate various mechanisms. For
example, the drive can open / close the pet feeder, move robot parts, etc.
10

Figure 2.1 – Ultrasonic distance sensor

Figure 2.2 – Servomotor

2.2 Examples of components usage


2.2.1 Ultrasonic distance sensor usage

Let’s look at an example of ultrasonic distance sensor usage. Sensor


and LED are located on circuit (Fig. 2.3). To run simulation, press "Start
simulation", then select sensor. After that area with an object will appear (Fig.
2.4). If distance to the object is bigger than 100cm, then LED lights up.
11

Figure 2.3 – Circuit with sensor

Figure 2.4 – Simulation of distance measuring


12

Code of the example:


int cm;
const int distanceThreshold = 100;
long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT);
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);

long duration = pulseIn(echoPin, HIGH);


long cmDistance = duration / 29 / 2;
}

void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT);
}

void loop()
{

cm = readUltrasonicDistance(7, 7);
Serial.print(cm);
Serial.print("cm, ");
if (cm > distanceThreshold)
{
digitalWrite(2, LOW);
}
if (cm <= distanceThreshold)
{
digitalWrite(2, HIGH);
}
delay(100);
}

2.2.2 Servomotor usage

In this example (Fig. 2.5) simple circuit with one servomotor is


created. After simulation started, servomotor starts spinning left-right every 2
seconds.
13

Figure 2.5 – Circuit with servomotor

Code of the example:


#include <Servo.h>
Servo servo_9;

bool b = true;

void setup()
{
Serial.begin(9600);
servo_9.attach(9);
}

void loop()
{
if (b)
{
servo_9.write(180);
b = false;
}
else
{
servo_9.write(-180);
b = true;
}
delay(2000);
}
14

2.3 Work assignment

2.3.1 Create circuit as in Fig. 2.4 and Fig. 2.5. Add code, Start
simulation and see what happens.
2.3.2 Add five LEDs. If distance to object is less than 50cm, then all
LEDs turn on. If distance is bigger than 300cm then all LEDs turn off. If
distance is more than 50cm and less than 100cm -> 4 LEDs turn on. If
distance is more than 100cm and less than 150cm -> 3 LEDs turn on. If
distance is more than 150cm and less than 200cm -> 2 LEDs turn on. If
distance is more than 200cm and less than 300cm -> one LEDs turn on.
2.3.3 Add servomotor. Servomotor position by default is 90 degrees.
If distance to object is less than 100cm, then servomotor turns around to 0
degrees, if servomotor more than 100cm turns around to 180 degrees.

2.4 Content of the report

2.4.1 Topic and goal of work.


2.4.2 Screenshots and code of created projects.
2.4.3 Conclusions.
15

Laboratory work №3
RGB LED and smoke detector

Goal: get started with RGB LED and smoke detector, learn to create
Arduino circuits using these components in Tinkecad.

3.1 Brief theory

The RGB LED consists of three different LEDs: red, green and blue.
By mixing these colors, we can get many other colors. Arduino has an analog
recording function that receives different colors for Arduino RGB LEDs [3].
There are two types of RGB LEDs: common cathode and common
anode. In RGB LEDs with a common cathode all LEDs are common and the
signal is transmitted to the anode of the LED, while in RGB LEDs with a
common anode the anode of all LEDs is common and the signal is transmitted
to the cathode of the LED [3].
In Tinkercad environment LED with common cathode is used.
In Fig. 3.1 RGB LED scheme is depicted.

Figure 3.1 – RGB LED scheme [3]

Consider a smoke detector on the example of a component


codenamed MQ-2.
The MQ-2 smoke detector is sensitive to smoke and the following
flammable gases:
16

• Liquefied petroleum gas;


• Bhutan;
• Propane;
• Methane;
• Ethanol;
• Hydrogen.
The resistance of the sensor varies depending on the type of gas.
The smoke detector has a built-in potentiometer that allows you to
adjust the sensitivity of the sensor according to how accurately you need to
detect gas [3].

Figure 3.2 – Smoke detector MQ-2

The voltage emitted by the sensor varies according to the level of


smoke / gas in the atmosphere. The sensor emits a voltage proportional to the
smoke / gas concentration [4].
In other words, the relationship between voltage and gas
concentration is:
• the higher the gas concentration, the higher the output voltage;
• the lower the gas concentration, the lower the output voltage [4].

3.2 Examples of components usage


3.2.1 RGB LED usage
17

Consider example of RGB LED usage. LED is located on circuit


(Fig.3.3). You can change the color by changing the analog signal to each of
the color outputs.

Figure 3.3 – Circuit with RGB LED

In Fig. 3.4 there is a table of primary colors and their RGB codes.
Code of the example:
void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}

void loop()
{
analogWrite(8, 0); // Green
analogWrite(9, 0); // Blue
analogWrite(10, 255); // Red
}
18

Figure 3.4 – Primary RGB colors

3.2.2 Smoke detector usage

In this example (Fig. 3.5) circuit with smoke detector and LED is
created.

Figure 3.5 – Circuit with smoke detector


19

If the smoke concentration exceeds a certain value, the LED lights


up.
In order to "create smoke" in the Tinkercad simulation mode, you
need to click on the smoke detector and move smoke cloud with mouse on the
work area.
Code of the example:
int led = 2;
int smokeA0 = A0;
int sensorThres = 70;
const int MIN_SENSOR_VALUE = 85;
const int MAX_SENSOR_VALUE = 385;

void setup()
{
pinMode(led, OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);
}

void loop()
{
int analogSensor = analogRead(smokeA0);
Serial.print("Gas sensor value: ");
Serial.println(analogSensor);
// change the sensor value (reading from 85 to 385) in the range of
[0; 100]
int gas = map(analogSensor, MIN_SENSOR_VALUE, MAX_SENSOR_VALUE, 0,
100);
Serial.print("After mapping: ");
Serial.println(gas);
if (gas > sensorThres)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
delay(100);
}
20

3.3 Work assignment

3.3.1 Create a circuit as shown in Fig. 3.3 and add code. Change
values of signals and analyze how the color of the RGB LED changes.
3.3.2 Create a circuit as shown in Fig. 3.5 and add the code. Add
LED to the circuit and change the program as follows:
• If the value of the smoke sensor is less than 25 - the LED lights up
green.
• If the smoke sensor value is 25 to 50 - yellow.
• If the smoke sensor value is 50 to 75 - orange.
• If the smoke sensor value is more than 75 - red.

3.4 Content of the report

3.4.1 Topic and goal of work.


3.4.2 Screenshots and code of created projects.
3.4.3 Conclusions.
21

Laboratory work №4
Photoresistor

Goal: get started with photoresistor, learn to create Arduino circuits


using this component in Tinkecad.

4.1 Brief theory

In industry and consumer electronics, photoresistors are used to


measure illuminance. Its main purpose is to convert the amount of light falling
on a sensitive area into a useful electrical signal. The signal can be further
processed by analog, digital logic circuit or circuit that takes into account the
microcontroller [5].
A photoresistor is a semiconductor device whose resistance varies
depending on how brightly its sensitive surface is illuminated.
The principle of operation is following: between the two electrodes
is a semiconductor. When a semiconductor is not illuminated, its resistance is
high, up to MOhm. When this area is illuminated, its conductivity increases
and the resistance decreases accordingly [5].
Materials such as cadmium sulfide, lead sulfide, cadmium selenite
and others can be used as semiconductors. Photoresistor's spectral
characteristic depends on the choice of material during the manufacture [5].
In Fig. 4.1 an example of photoresistor is depicted.

Figure 4.1 – Photoresistor

4.2 Example of component usage


4.2.1 Photoresistor usage

Consider an example of photoresistor usage. Photoresistor is located


on circuit (Fig. 4.2). In order to work with photoresistor in the simulation
22

mode in Tinkercad environment, click on the photoresistor and change the


position of the slider that appears.
In the example, when you change the illuminance of the
photoresistor, the light intensity of the LED changes.

Figure 4.2 – Circuit of photoresistor

Code of the example:


int sensorValue = 0;
const int MIN_SENSOR = 6;
const int MAX_SENSOR = 679;

void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
23

pinMode(9, OUTPUT);
}

void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorValue);
// map the sensor reading to a range for the LED
analogWrite(9, map(sensorValue, MIN_SENSOR, MAX_SENSOR, 255, 0));
delay(100); // Wait for 100 millisecond(s)
}

4.3 Work assignment

4.3.1 Create circuit as in Fig. 4.2 and add code.


4.3.2 Add servomotor that turns on 0, 90 and 180 degrees according
to illuminance of photoresistor.

4.4 Content of the report

4.4.1 Topic and goal of work.


4.4.2 Screenshots and code of created projects.
4.4.3 Conclusions.
24

Laboratory work №5
Motion sensor

Goal: get started with motion sensor, learn to create Arduino circuits
using this component in Tinkecad.

5.1 Brief theory

Passive infrared motion sensor (PIR) allows you to track the


movement in a closed area of objects that emit heat (humans, animals). Such
systems are often used in domestic conditions, for example, to turn on the light
in room [6].
The design of the motion sensor is not very complicated: it consists
of a pyroelectric element with high sensitivity (a cylindrical part in the center
of which is a crystal) to the presence in the area of a certain level of infrared
radiation. The higher the temperature of the object, the more radiation. A
hemisphere is installed on top of the PIR sensor, divided into several sections
(lenses), each of which provides focusing of thermal energy radiation on
different segments of the motion sensor. Fresnel lens are most often used as a
lens, which due to the concentration of thermal radiation allows to expand the
range of sensitivity of the infrared motion sensor [6].
In Fig. 5.1 motion sensor is depicted.

Figure 5.1 – Motion sensor [6]

The PIR sensor is structurally divided into two halves. This is due to
the fact that for the alarm device it is important to have movement in the
sensitivity zone, and not the level of radiation [6].
25

The principle of operation of the motion sensor is following:


1. When the device is installed in an empty room, the radiation dose
received by each element is constant, as the voltage is;
2. With the appearance of a person in the room, he first enters the
field of view of the first element, in which a positive electrical impulse is
formed;
3. When a person moves around the room, the heat radiation, which
falls on the second sensor, moves with him. This PIR element generates a
negative pulse;
4. Divergent pulses are registered by the electronic circuit of the
sensor, which concludes that there is a person in the field of view of the sensor
[6].

5.2 Example of component usage


5.2.1 Motion sensor usage

Consider an example of motion sensor usage. Motion sensor is


located on circuit (Fig. 5.2). In order to work with the motion sensor in the
simulation mode in the Tinkercad environment, you need to click on the
sensor and change the position of the object with the mouse cursor in the area
that appears.
In the example, while the object is moving in the field of view of the
sensor, the LED lights up.
Code of the example:
int sensorState = 0;
int sensorPin = 3;
int ledPin = 13;

void setup()
{
pinMode(sensorPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);

void loop()
{
// read the state of the sensor/digital input
sensorState = digitalRead(sensorPin);
// check if sensor pin is HIGH. if it is, set the
// LED on.
26

if (sensorState == HIGH)
{
digitalWrite(ledPin, HIGH);
Serial.println("Sensor activated!");
}
else
{
digitalWrite(ledPin, LOW);
}
delay(100); // Delay a little bit to improve simulation performance
}

Figure 5.2 – Circuit with motion sensor

5.3 Work assignment

5.3.1 Create circuit as in Fig. 5.2 and add code.


27

5.3.2 Add photoresistor. If the photoresistor illuminance is more than


half and in the field of view of the motion sensor motion is detected, the LED
lights up.

5.4 Content of the report

5.4.1 Topic and goal of work.


5.4.2 Screenshots and code of created projects.
5.4.3 Conclusions.
28

Laboratory work №6
Temperature sensor

Goal: get started with temperature sensor, learn to create Arduino


circuits using this component in Tinkecad.

6.1 Brief theory

Analog temperature sensor is easy to learn, cheap and at the same


time allows you to control the temperature in real time [7].
These sensors use solid-state electronics technology to determine
temperature. They have thermistors (temperature-sensitive resistors). In
thermistors, when the temperature rises, the voltage in the diode increases
(technically, this is the voltage difference between the base and the emitter in
the transistor). Accurate voltage reading make it possible to generate an
analog signal proportional to the temperature [7].
In Fig. 6.1 temperature sensor is depicted.

Figure 6.1 – Temperature sensor

These sensors have no moving parts, they are accurate, practically do


not wear out, do not require calibration, can work in different environments. In
addition, these sensors are cheap and easy to use [7].
29

6.2 Example of component usage


6.2.1 Temperature sensor usage

Consider an example of temperature sensor usage. Photoresistor is


located on circuit (Fig. 6.2). In order to work with the temperature sensor in
the simulation mode in the Tinkercad environment, click on sensor and change
the position of temperature slider with mouse in the area that appears.
In the following example, as the temperature increases, the LEDs
start to light up sequentially.

Figure 6.2 – Circuit with temperature sensor

Code of the example:


const int Temp1 = 40;
const int Temp2 = 80;
double temp = 0;
30

void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);

pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}

void loop()
{
int sensorValue = analogRead(A0);
// measure temperature in Celsius
temp = (double) sensorValue / 1024; //find percentage of input
reading
temp = temp * 5; //multiply by 5V to get voltage
temp = temp - 0.5; //Subtract the offset
temp = temp * 100; //Convert to degrees
Serial.print(temp);
Serial.println(" C");
if (temp < Temp1) {
digitalWrite(2, 0);
digitalWrite(3, 0);
digitalWrite(4, 255);
}
if (temp >= Temp1 && temp < Temp2) {
digitalWrite(2, 0);
digitalWrite(3, 255);
digitalWrite(4, 255);
}
if (temp >= Temp2) {
digitalWrite(2, 255);
digitalWrite(3, 255);
digitalWrite(4, 255);
}
delay(500); // Wait for 500 millisecond(s)
}

6.3 Work assignment

6.3.1 Create circuit as in Fig. 6.2 and add code.


6.3.2 Change LEDs with one RGB LED. Add the following color
change condition:
• When temperature is below 18°C – blue;
31

• When temperature is between 18°C and 50°C – green;


• When temperature is above 50°C – red.

6.4 Content of the report

6.4.1 Topic and goal of work.


6.4.2 Screenshots and code of created projects.
6.4.3 Conclusions.
32

Laboratory work №7
Group of sensors

Goal: get started with moisture sensor, learn to create Arduino


circuits with group of sensors in Tinkecad.

7.1 Brief theory

The soil moisture sensor consists of two probes that measure the
volume of water in the soil. The two probes allow the electric current to pass
through the soil and, according to its resistance, measures the moisture level of
the soil [8].
When there is more water, the soil conducts more electricity, which
means that the resistance will be less. So the moisture level will be higher. Dry
soil reduces conductivity. So, when there is less water, the soil conducts less
electricity, which means it has more resistance. So the moisture level will be
lower [8].
In Fig. 7.1 moisture sensor is depicted.

Figure 7.1 – Soil moisture sensor


33

7.2 Example of component usage


7.2.1 Soil moisture sensor usage

Consider an example of moisture sensor usage. Sensor is located on


circuit (Fig. 7.2). In order to work with the moisture sensor in the simulation
mode in the Tinkercad environment, click on sensor and change the position
of moisture slider with mouse in the area that appears.
In the following example, as the moisture increases more than 50%,
the LED starts to light up.

Figure 7.2 – Circuit with moisture sensor


34

Code of the example:


int led = 2;
int moistureThres = 50;
const int MIN_SENSOR_VALUE = 0;
const int MAX_SENSOR_VALUE = 876;

void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(A0, INPUT);
//pinMode(2, OUTPUT);
}

void loop()
{
int moisture = analogRead(A0);
int moisturePercent = map(moisture, MIN_SENSOR_VALUE,
MAX_SENSOR_VALUE, 0, 100);
Serial.println(moisturePercent);
if (moisturePercent > moistureThres)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
delay(100);
}

7.2.2 Group of sensors usage

A smart home system usually uses multiple sensors at once to give


the user a complete picture of what's going on in their home.
In Fig. 7.3 usage of multiple sensors is depicted (temperature,
luminance, distance, motion, gas). Data that is collected from sensors returns
to console.
35

Figure 7.3 – Circuit with group of sensors

Code of the example:

void setup()
{
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);

Serial.begin(9600);
}

void loop()
{
double temperature = getTemperature();
Serial.print("Temperature: ");
Serial.println(temperature);

bool isSomeoneMoving = isMoving();


Serial.print("Motion detected: ");
Serial.println(isSomeoneMoving);

int luminance = getLuminance();


Serial.print("Luminance: ");
Serial.println(luminance);

long distance = getDistance(A2, A2);


Serial.print("Distance: ");
Serial.println(distance);
36

int gas = getGas();


Serial.print("Gas value: ");
Serial.println(gas);

Serial.println();
delay(1000); // Wait for 500 millisecond(s)
}

double getTemperature()
{
int sensorValue = analogRead(A5);
double temp = (double) sensorValue / 1024; //find percentage of
input reading
temp = temp * 5; //multiply by 5V to get voltage
temp = temp - 0.5; //Subtract the offset
temp = temp * 100; //Convert to degrees
return temp;

bool isMoving()
{
return (bool)digitalRead(A4);
}

int getLuminance()
{
return analogRead(A3);
}

long getDistance(int triggerPin, int echoPin)


{
pinMode(triggerPin, OUTPUT);
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);

long duration = pulseIn(echoPin, HIGH);


long cmDistance = duration / 29 / 2;
return cmDistance;
}

int getGas()
{
37

int analogSensor = analogRead(A1);


// change the sensor value (reading from 85 to 385) in the range of
[0; 100]
int gas = map(analogSensor, 85, 385, 0, 100);
}

7.3 Work assignment

7.3.1 Create circuit as in the examples and add code.


7.3.2 Add moisture sensor to the group of sensors and output data to
console.

7.4 Content of the report

7.4.1 Topic and goal of work.


7.4.2 Screenshots and code of created projects.
7.4.3 Conclusions.
38

Sources of useful information

1. Ultrasonic distance sensor HC-SR04 (US-025) [Electronic


resource]. – Access mode: https://radarkr.com.ua/ua/p1440312760-
ultrazvukovoj-datchik-
izmereniya.html?source=merchant_center&gclid=Cj0KCQiAr5iQBhCsARIsA
PcwROOirbqjNKkFZIAOoUYjHBKJCgTUkkYh1ByU4D7yFO6eJ7NgttqJxf
gaAkg-EALw_wcB.
2. Servo drives: device, principle of operation and main types
[Electronic resource]. – Access mode: http://wiki.amperka.ru/articles:servo.
3. Arduino RGB LED Tutorial [Electronic resource]. – Access
mode: https://create.arduino.cc/projecthub/muhammad-aqib/arduino-rgb-led-
tutorial-fc003e.
4. Smoke Detection using MQ-2 Gas Sensor [Electronic resource]. –
Access mode: https://create.arduino.cc/projecthub/Aritro/smoke-detection-
using-mq-2-gas-sensor-79c54a.
5. What are photoresistors, how they work and where they are used
[Electronic resource]. – Access mode: https://samelectrik.ru/chto-takoe-
fotorezistory.html.
6. Arduino motion sensor [Electronic resource]. – Access mode:
https://arduinomaster.ru/datchiki-arduino/arduino-datchik-dvizheniya/
7. Temperature sensor TMP36 and Arduino [Electronic resource]. –
Access mode: https://arduino-diy.com/arduino-datchik-temperatury-TMP36.
8. Complete Guide to Use Soil Moisture Sensor w/ Examples
[Electronic recourse]. – Access mode:
https://create.arduino.cc/projecthub/electropeak/complete-guide-to-use-soil-
moisture-sensor-w-examples-756b1f.

You might also like