You are on page 1of 57

NORZAGARAY COLLEGE

Municipal Compound, Norzagaray, Bulacan

LEARNING MODULE
IN
ROBOTICS
(FRELEC103)

FINAL TERM
1ST SEMESTER A.Y. 2021-2022

Rex M. Ramirez
Subject Instructor

College of Computing Studies


This learning module is for teaching and learning purposes only.
No part of this learning module shall be printed, electronically or
mechanically reproduced, and shared publicly to any form of
social media/online platforms. Anyone who will be directly and
indirectly involved shall be administratively dealt with.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 1
TABLE OF CONTENTS

LEARNING TASK 12--------------------------------------------------- ------------------------------------3


PRE-ASSESSMENT 12-------------------------------------------------------------------------------------3
COURSE CONTENT-----------------------------------------------------------------------------------------3
POST-ASSESSMENT 12----------------------------------------------------------------------------------19

LEARNING TASK 13---------------------------------------------------------------------------------------19


PRE-ASSESSMENT 13------------------------------------------------------------------------------------19
COURSE CONTENT 13-----------------------------------------------------------------------------------20
Arduino Stepper Motor--------------------------------------------------------------------------------------20
Arduino Servo Motor-----------------------------------------------------------------------------------------23
Arduino Servomotor using Potentiometer--------------------------------------------------------------26
Arduino DC motor--------------------------------------------------------------------------------------------29
POST ASSESSMENT 13-----------------------------------------------------------------------------------36

LEARNING TASK 14---------------------------------------------------------------------------------------37


PRE-ASSESMENT 14--------------------------------------------------------------------------------------37
COURSE CONTENT----------------------------------------------------------------------------------------37
Blinking two LED----------------------------------------------------------------------------------------------39
Arduino Switch------------------------------------------------------------------------------------------------43
Arduino Button------------------------------------------------------------------------------------------------46
Arduino Potentiometer--------------------------------------------------------------------------------------50
Arduino Simulator--------------------------------------------------------------------------------------------51
POST-ASSESMENT 14------------------------------------------------------------------------------------57

Final Examination------------------------------------------------------------------------------------------58

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 2
LEARNING TASK 12 (Week 13)
November 29-December 4, 2021

Desired Learning Outcomes

Upon completion of this material, you should be able to:


• Communication principles and methods for sensors
• Learn the use of microcontrollers (Ardunio).
• Learn how to connect and read information from sensors.

Pre-Assessment 12

Answer the following questions. Write your answers on a separate sheet of long bond
paper.

1. What is the meaning of sensor?


2. Give atleast 9 types of of sensor. Explain?

Scoring Rubric:
Content/Idea: 5pts.
Coherence: 3pts.
Handwriting: 2pts.
Total Score: 10pts.

Course Content

Arduino is the open-source platform used for making custom electronics projects.
Before learning about the Arduino Sensors, lets first understand the sensors as a general
term.

What are the sensors?


The sensors are defined as a machine, module, or a device that detect changes in the
environment. The sensors transfer those changes to the electronic devices in the form of a
signal.
A sensor and electronic devices always work together. The output signal is easily
readable by humans.
Nowadays, Sensors are used in daily lives. For example, controlling the brightness of the
lamp by touching its base, etc. The use of sensors is expanding with new technologies.

What is a sensor made of?

The sensor is a device, which is made up of Single Crystal Silicon. It is considered as a


widely used semiconductor material. It has superior mechanical stability, machinability,
etc. It can also combine electronics and sensing elements on the same substrate.

Where are the sensors used?

The sensors are used to measure the physical quantities, such as pressure, temperature,
sound, humidity, and light, etc.

An example of sensors is Fire Alarm, a detector present on the fire alarm detects the
smoke or heat. The signal generated from the detector is sent to the alarming system,
which produces an alert in the form of alarm.

The types of detectors are smoke detectors, heat detectors, carbon monoxide detectors,
multi-sensors detectors, etc.

How are the sensors used in Arduino?

The data signal runs from the sensor to the output pins of the Arduino. The data is further
recorded by the Arduino.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 3
What are the types of sensors in Arduino?
Some of the types of sensors in Arduino are listed below:
o Light sensor
The light sensor is used to control the light. It is used with LDR (Light
Dependent Resistor) in Arduino.

o Ultrasonic sensor
The ultrasonic sensor is used to determine the distance of the object using
SONAR.
o Temperature sensor
The temperature sensor is used to detect the temperature around it.
o Knock Sensor
The knock sensor is used to pick the vibrations of the knocking. It is a
common category of a vibration sensor.
o Object Detection Sensor
It is used to detect the object by emitting infrared radiations, which are
reflected or bounced back by that object.
o Tracking Sensor
It allows the robots to follow a particular path specified by sensing the marking or lines on
the surface.
o Metal Touch Sensor
It is suitable for detecting the human touch.
o Water Level Sensor
It is used to measure the water or the depth of the water level. It is
also used to detect leaks in containers.
o Vibration Sensor
The vibration sensor is used to measure the vibrations.
o Air Pressure sensor
It is commonly related to meteorology, biomedical fields. It looks like the below
image:

o Pulse Sensor
The pulse sensor is used to measure the pulse rate. It looks like the below image:

o Capacitive soil moisture sensor


It is used to measure the moisture level of the soil.
o Microphone sensor
The microphone sensor in Arduino is used to detect the sound.
The analog and digital are the two outputs of this module. The digital output
sends the high signal when the intensity of sound reaches a certain threshold. We can
adjust the sensitivity of a module with the help of a potentiometer.
o humidity sensor
The humidity sensor is used to monitor weather conditions.
o Motion sensor
The motion sensor detects the movement and occupancy from the human
body with the help of Infrared radiation.
o Vibration sensor
The vibration sensor is used to detect the vibrations.
o Sound sensor
The sound sensor is suitable to detect the sound of the environment.
o Pressure Sensor
The pressure sensor is used to measure the pressure. The sensor in
Arduino measures the pressure and displays it on the small LCD screen.

Learn more
o Magnetic field sensor
The magnetic field sensor measures the magnetic field strength and produces a varying
voltage as the output in Arduino.

Arduino LDR

Arduino LDR (Light Dependent Resistor) project uses the photoresistor to light an LED.
The LED will light up whenever there is dark or no light over the sensor.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 4
What is photoresistor?

It is defined as a light-controlled resistor, which is also called as LDR. It is a variable


resistor that controls the resistance in accordance with the received light intensity. It
means, the resistance decreases as intensity of light increases.

Let's start with the project.

Hardware Required

The components required for the project are listed below:

o 1 x red LED
o 1 x 220 Ohm Resistor
o 1 x 10K Ohm Resistor
o Arduino UNO R3 board
o Jump wires
o 1 x photoresistor

We can use any color LED as per our choice.

Structure of the project

The structure of the project is shown below:

How to calculate the output voltage using photoresistor?

The structure of photoresistor is shown below:

The formula to calculate the dark output voltage is given below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 5
where,

Vin = 5V

Vout = Output voltage

Here, R2 is the resistance connected in series with the photoresistor = 10K Ohm.

R1 is the resistance of the photoresistor.

Note: The resistance decreases with increasing light. Hence, the output voltage will
increase. It means that the output voltage calculated at the light will be higher than the
output voltage calculated at dark.

Here, dark and light specify the light falling on the sensor.

Connection

The connection of the above project is discussed below:

o Connect the positive leg of the LED in series with the resistor to the pin number 12
of the Arduino board.
o Connect the negative leg of the LED to the Ground.
o Connect one edge of the photoresistor to the 5V pin on the Arduino board.
o Attach a 10K ohm resistance in series with another edge of the photoresistor and
connect it to the GND.
o Connect the edge of the photoresistor to the analog pin A0.

Note: We have connected the LED only to enhance the project. We can also create the
project without using the LED. It will not impact the output.

Sketch Consider the below code:

const int LEDpin = 12;


const int photoPIN = A0;

void setup() {
// initializing the serial communication:
Serial.begin(9600);
pinMode(photoPIN, INPUT);
pinMode(LEDpin, OUTPUT);
}
void loop() {
// read the sensor:
int sensorStatus = analogRead(photoPIN);
// now, it will check the reading or status of the sensor is < 200
// if it is, LED will be HIGH
if (sensorStatus <200)
{
digitalWrite(LEDpin, HIGH); // LED is ON
Serial.println(" LED is ON, status of sensor is DARK");

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 6
}
else
{
digitalWrite(LEDpin, LOW);
Serial.println(" ***************");
}
}

Connection Diagram

The connection diagram is shown below:

Output

The output on the serial monitor will appear as:

LED is one because there is dark over the sensor.

Arduino Accelerometer

In this topic, we will discuss a project based on an accelerometer. The value will be read
from the series of accelerometer and received in the Arduino IDE's

serial monitor. It means the data will be read and received over the serial port.

We will use a three-axis accelerometer that gives acceleration for each Axis as an analog
voltage for separate pins.

We would be using the ADXL3xx accelerometer series. For example, ADXL320,


ADXL322, ADXL321, ADXL335, etc.

In this project, we are going to work with the ADXL335 accelerometer.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 7
What is accelerometer?

The accelerometer is the device capable of detecting changes in motion in the form of
acceleration. It can also measure the vibration of a structure.

The acceleration is defined as the change in speed or velocity over time.

The motion sensors are present inside the accelerometer.

How does accelerometer work?

The acceleration (change in motion) or the vibration generates the force that causes the
piezoelectric material to be stressed. The microscopic crystals structure present in it
creates the voltage from the stress. The accelerometer interprets this voltage. The voltage
is further used to determine the orientation and velocity.

Usage of Accelerometer

The uses of the accelerometer are listed below:

o It is used to detect earthquakes due to the presence of a motion sensor.


o It is present on the laptop, which protects the hard drives from damage.
o It is used to create custom projects.
o It can determine the movements (uphill, etc.) of the object.

ADXL335 Accelerometer

The structure of ADXL335 is shown below:

The position of the three axis (X-axis, Y-axis, and Z-axis) will change according to the
ADXL335 accelerometer's position.

If we hold the board in a different position, the direction of the three-axis will also change.
Moving the board in a particular direction will cause a change in the voltage of the
respective axis. We can measure the changed voltage on the Arduino

When we hold the board up and flat, the measured acceleration of 9.8m/s^2 will appear
on the Z-axis.

It is also called as the gravity. Here,

1.0G = of 9.8m/s^2

where,

G is the acceleration due to earth gravity.

The sensitivity of ADXL335 accelerometer is:

s = 0.33V/G.

Gravity force per ADC (Analog to Digital Converter) unit is:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 8
It is because the sensors need 3.3V to operate.

The accelerometer at rest will read half of its maximum analog voltage.

Note: Some accelerometers work at 5V while some at 3.3V. We need to make sure about
the voltage because the 3.3V accelerometer may be damaged with a 5V supply.

Let's start the project.

Hardware Required

The components required for the project are listed below:

o 1 x ADXL335 accelerometer
o 1 x Arduino UNO R3

Principle

We can directly plugged-in the accelerometer onto the Arduino. It is because the
accelerometer operates on minimal current.

The Arduino UNO

has six analog pins. The three analog pins will be connected to the Vcc, Self-Test, and the
Ground pin. The other three analog pins will be used to read the analog output of the
accelerometer.

Structure

The structure of the project is shown below:

Connection

The connection for the above project is explained below:

o Connect X of the accelerometer to the analog pin A3 of the Arduino board.


o Connect Y of the accelerometer to the analog pin A2 of the Arduino board.
o Connect X of the accelerometer to analog pin A1 of the Arduino board.
o Connect Vcc of the accelerometer to analog pin A5 of the Arduino board.
o Connect GND of the accelerometer to analog pin A4 of the Arduino board.
o Connect ST of the accelerometer to analog pin Ao of the Arduino board.

Sketch

We will upload the code on the Arduino connected with the accelerometer. The output can
be clearly seen on the Serial Monitor in the Arduino IDE

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 9
Consider the below code

1. const int GND = A4;


2. const int PowerPIN = A5;
3. const int pinOfX = A3;
4. const int pinOfY= A2;
5. const int pinOfZ= A1;
6. void setup()
7. {
8. Serial.begin(9600);
9. pinMode(GND , OUTPUT);
10. pinMode(PowerPIN , OUTPUT);
11. digitalWrite(GND , LOW); // configuring the GND pin as LOW
12. digitalWrite(PowerPIN , HIGH); // configuring the power pin HIGH (5V/3.3V)
13. }
14. void loop()
15. {
16. // It prints the values of the sensors
17. Serial.print(analogRead(pinOfX)); // print a tab between values:
18. Serial.print("\t");
19. Serial.print(analogRead(pinOfY));
20. Serial.print("\t");
21. Serial.print(analogRead(pinOfZ));
22. Serial.println(); // It delays before next reading
23. delay(100);
24. }

Arduino Ultrasonic distance sensor

The Ultrasonic sensor or HC-SRO4 is used to measure the distance of the object using
SONAR.

It emits the Ultrasound at a frequency of 40KHZ or 40000 Hz. The frequency travels
through the air and strikes the object on its path. The rays bounce back from the object
and reach back to the module.

The four terminals of HC-SRO4 are VCC, TRIG, ECHO, and GND. The voltage supply or
VCC is +5V. We can connect the ECHO and TRIG terminal to any of the digital I/O pin on
the specific Arduino board.

The Ultrasonic sensors work best for medium ranges.

The resolution is 0.3cm.

The medium ranges of the sensor are 10cm to 3m. It works best at this duration.

The maximum range the sensor may detect is 4.5m.

How does Ultrasonic sensor work?

Let's understand how the sensor works.

o It sends ultra-high frequency samples.

o When samples strike the object, it bounces back from the object.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 10
o The distance sensor reports the time it takes between the sending and receiving of
the samples.

Example

Let's consider an example.

An object is 40cm away from the Ultrasonic sensor. The speed of sound in air is
340m/s. We need to calculate the time (in Microseconds).

Solution:

v = 340m/s = 0.034cm/us (centimeter/microseconds)

time = distance/speed

time = 40/0.034

time = 1176 microseconds

The speed of sound from the echo pin will double because the wave travels forward and
backward (bounces).

So, to calculate the distance, we need to divide it by 2. It is shown below:

distance = time x speed of sound/2

distance = time x 0.034/2

Structure of Ultrasonic Sensor

The structure of HC-SRO4 is shown below:

Ultrasonic sensor Timing Diagram

We will set the TRIG pin to HIGH for some time (about 3 to 100 microseconds). As soon
the TRIG pin is LOW, the Ultrasonic sensor sends the pulses and sets the ECHO pin to
HIGH. When the sensor gets the reflected pulses, it sets the ECHO pin to LOW. We need
to measure the time for which the ECHO pin was HIGH.

The timing diagram of the ultrasonic sensor HC-SRO4 is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 11
Let's start creating the Arduino

ultrasonic sensor to measure distance.

Hardware Required

The components required to create the project are listed below:

o Arduino UNO R3 board (We can also use any Arduino board)
o Jump wires
o Ultrasonic sensor HC-SRO4
o Breadboard

Principle

We need to first set the TRIG (triggered) pin at HIGH. It will send out the burst of 8 cycles
called the sonic burst, which will travel at the sound speed. It will be further received by
the ECHO pin. The time traveled by the sound wave is considered the ECHO pin's output
time in microseconds.

We will use the PulseIn() function to read the time from the output of the ECHO pin. It will
wait for the specified pin to go HIGH and LOW. The function would return the timing at the
end.

The TRIG pin is set LOW for 4 microseconds and then HIGH for 15 microseconds.

The timing will be calculated in microseconds.

Procedure

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 12
The steps to connect the Ultrasonic sensor to the board are listed below:

o Connect the VCC pin of HC-SRO4 to 5V of the Arduino board.


o Connect the GND pin of HC-SRO4 to GND of the Arduino board.
o Connect the TRIG pin of HC-SRO4 to pin 6 of the Arduino board.
o Connect the ECHO pin of HC-SRO4 to pin 5 of the Arduino board.

Sketch

Consider the below code:

1. #define ECHOpin 5 // it defines the ECHO pin of the sensor to pin 5 of Arduino
2. #define TRIGpin 6
3. // we have defined the variable
4. long duration; // variable for the duration of sound wave travel
5. int distance; // variable for the distance measurement
6. void setup()
7. {
8. pinMode(TRIGpin, OUTPUT); // It sets the ECHO pin as OUTPUT
9. pinMode(ECHOpin, INPUT); // It sets the TRIG pin as INPUT
10. Serial.begin(9600); // // Serial Communication at the rate of 9600 bps
11. Serial.println("Test of the Ultrasonic Sensor HC-
SR04"); // It will appear on Serial Monitor
12. Serial.println("with the Arduino UNO R3 board");
13. }
14. void loop()
15. {
16. // It first sets the TRIG pin at LOW for 2 microseconds
17. digitalWrite(TRIGpin, LOW);
18. delayMicroseconds(4);
19. // It now sets TRIG pin at HIGH for 15 microseconds
20. digitalWrite(TRIGpin, HIGH);
21. delayMicroseconds(15);
22. digitalWrite(TRIGpin, LOW);
23. // It will read the ECHO pin and will return the time
24. duration = pulseIn(ECHOpin, HIGH);
25. // distance formula
26. distance = duration*(0.034/2); // (speed in microseconds)
27. // Speed of sound wave (340 m/s)divided by 2 (forward and backward bounce)
28. // To display the distance on Serial Monitor
29. Serial.print("Distance: ");
30. Serial.print(distance);
31. Serial.println(" cm"); //specified unit of distance
32. }

Steps to upload the code to the project

The steps are listed below:

o Open the Arduino IDE.


o Select the type of board from Tools -> Board -> Arduino UNO.
o Select the port from Tools -> Port -> COM..
o Upload the sketch to the connection diagram.

Connection Diagram

The connection diagram is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 13
Output

The output on the serial monitor will appear as:

Arduino temperature sensor

The temperature sensor in Arduino converts the surrounding temperature to voltage. It


further converts the voltage to Celcius, Celcius to Fahrenheit, and prints the Fahrenheit
temperature on the LCD screen.

We will use a temperature sensor (TMP 36) of low voltage. Such sensors are also stable
while dealing with large capacitive loads. It is also suitable for automotive applications.

The temperature sensors TMP 35, TMP 36, and TMP 37 are the sensors with the same
features.

The operating voltage of the TMP 36 sensor ranges from 2.7V to 5.5V.

The sensor will look like the image shown below:

It has three terminals, which are listed below:

o Pin 1: DC voltage

Here, we will connect the DC voltage pin to 5V on the Arduino UNO board.

o Pin 2: Analog voltage output

We will consider the Analog voltage output pin as the output.

o Pin 3: GND

We will connect the GND pin to Ground on the Arduino UNO board.

Let's start the project.

Hardware Required

The components required for the project are listed below:

o 1 x TMP 36 sensor (Temperature sensor)


o 1 x LCD display
o Arduino UNO R3 board (We can take any Arduino board).
o Jump wires

Principle

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 14
We will connect the LCD Display and TMP 36 temperature sensor with the Arduino UNO
R3 board. The sensor detects the surrounding temperature and converts it into volts, to
Celsius to Fahrenheit, and displays Fahrenheit temperature on the LCD screen.

We need to open the URL: Arduino LCD display for details about LCD display.

Connection

The steps to set up the connection are listed below:

o Connect the RS pin of LCD to pin 13 of the Arduino board.


o Connect the Enable pin of LCD to pin 12 of the Arduino board.
o Connect the D4 pin of LCD to pin 6 of the Arduino board.
o Connect the D5 pin of LCD to pin 4 of the Arduino board.
o Connect the D6 pin of LCD to pin 3 of the Arduino board.
o Connect the D7 pin of LCD to pin 2 of the Arduino board.
o Connect the Vo pin of LCD to pin 8 of the Arduino board.
o Connect the middle terminal to a sensor to A0(analog pin).
o Connect one end of the sensor to GND and another end to 5V.
o Connect one end of a resistor to the A and K of the LCD and another end to 5V.

Sketch

Consider the below code:

1. #include <LiquidCrystal.h>
2. // initialize the library with the pins on the Arduino board
3. LiquidCrystal lcd(13, 12, 6, 4, 3, 2);
4. const int temperature = A0; //A0 is the analog pin
5. const int D = 8; // Vo of LCD is connected to pin 8 of the Arduino
6. void setup()
7. {
8. lcd.begin(16, 2);
9. Serial.begin(9600);
10. pinMode(D, OUTPUT);
11. }
12. void loop()
13. {
14. digitalWrite(D,LOW);
15. int Temp = analogRead(temperature);
16. float volts = (Temp / 965.0) * 5;
17. float celcius = (volts - 0.5) * 100;
18. float fahrenheit = (celcius * 9 / 5 + 32);
19. Serial.println(fahrenheit);
20. lcd.setCursor(5, 0);
21. lcd.print(fahrenheit);
22. delay(2000);
23. // time delay of 2000 microseconds or 2 seconds
24. }

We will show the connection using the Simulator because the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 15
Output

The output is now visible on the LCD screen.

For better understanding, let's consider the output on the Serial Monitor.

It is the temperature in Fahrenheit.

Arduino Motion Sensor

We will use a PIR motion sensor in this project. All objects (having temperature higher
than absolute zero) emit radiations from the generated heat. These radiations cannot be
detected by a human eye. Hence, electronic devices such as motion sensors, etc. are
used for the detection of these radiations.

What is a PIR sensor?

The Passive Infra-Red sensors or PIR sensors detect motion or movement of an object
that detect infrared radiations, such as the human body. Hence, the use of sensors is very
common.

The advantages of using a PIR sensor are listed below:

o Inexpensive
o Adjustable module
o Efficient
o Small in size
o Less power consumption
o It can detect motion in the dark as well as light.

The PIR sensor is shown below:

The PIR sensor has three terminals, which are listed below:

o VCC
o Digital Output
o GND (Ground)

We will connect the Vcc terminal of the sensor to the 5V on the Arduino board. The PIR's
sensor output can be connected to any of the digital pins on the Arduino board.

The applications of the PIR sensor are automation, security systems, etc. Such sensors
work great in detecting the entrance of a person in an area and leaving it.

The detection range of PIR sensors is from 5m to 12m.

Working of PIR Sensors

The working of the PIR sensor is entirely based on detecting the IR (Infra-Red) radiations,
which are either emitted or reflected by the objects.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 16
The infrared radiations are detected by the crystalline material present at the center of the
sensor.

Consider a person passing in front of the background like a wall, etc. The temperature
changes from room to body temperature and vice-versa within the sensor field. Changes
arising in the arrival infrared radiations are converted by the sensor to the output voltage.
It later detects the human body or object.

Structure of PIR Sensor

A round metal can is mounted on the center with the rectangular crystal that detects the IR
radiations.

A ball like a lens present on some sensors helps in enhancing the viewing angle.

The bottom part of the sensor contains many circuits mounted on it, which is shown
below:

Let's start with the project.

Hardware Required

The components required for the project are listed below:

o 1 x PIR motion sensor


o Arduino UNO R3 board (We can take any Arduino board).
o Jump wires
o 1 x red LED (we can take LED of any color)
o 1 x 220 Ohm resistor

Principle

The movement of jumper present on the sensor on the L side will cause a change in the
state of the sensor whenever the motion is detected. Such a condition is defined as a
single trigger mode.

When the sensor resets the timer after every detection of motion, it is defined as repeated
trigger mode.

The two potentiometers present on the sensor are called as Sensitivity Potentiometer
and Time Potentiometer. We can adjust both the parameters (time and sensitivity)
accordingly.

It should be restricted for atleast 15 seconds in front of the PIR sensor for proper
calibration in the output. After 15 seconds, the sensor can easily detect movements.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 17
If any movement is detected, the LED will be HIGH. If there is no such movement, the
output will be LOW.

Connection

The steps to set up the connection are listed below:

o Connect the Vcc terminal of the PIR sensor to the 5V pin of the Arduino board.
o Connect the Output terminal of the PIR sensor to pin 8 of the Arduino board.
o Connect the GND terminal of the PIR sensor to the Ground pin of the Arduino
board.
o Connect the positive leg of the LED in series with 220 Ohm resistor to pin 13 of the
Arduino board.
o Connect the negative terminal of the LED to the Ground pin of the Arduino board.

Sketch

Consider the below code:

1. int LEDpin = 13; // LED pin


2. int PIRpin = 8; // The pin of Arduino connected to the PIR output
3. int PIRvalue = 0; // It specifies the status of PIR sensor
4. void setup() {
5. pinMode(LEDpin, OUTPUT);
6. pinMode(PIRpin, INPUT);
7. // the output from the sensor is considered as input for Arduino
8. Serial.begin(9600);
9. }
10. void loop()
11. {
12. PIRvalue = digitalRead(PIRpin);
13. if (PIRvalue == HIGH)
14. {
15. digitalWrite(LEDpin, HIGH);
16. // turn ON LED if the motion is detected
17. Serial.println("hello, I found you...heyyy..");
18. }
19. else
20. {
21. digitalWrite(LEDpin, LOW);
22. // LED will turn OFF if we have no motion
23. Serial.println("I cannot find you");
24. delay(1000);
25. }
26. }

Steps to upload the code to the project

The steps are listed below:

o Open the Arduino IDE.


o Select the type of board from Tools -> Board -> Arduino UNO.
o Select the port from Tools -> Port -> COM..
o Upload the sketch to the connection diagram.

Connection Diagram

We will show the connection using the Simulator so that the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

The output will be based on the detection.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 18
POST- ASSESSMENT 12
Identification: Choose the correct answers.

Tracking Sensor Light DependentResistor Metal Touch Presure Sensor


humidity sensor Object Detection Sensor Water Level Capacitive soil
Sensors Ultrasonic sensor Viabration moisture sensor
Air Pressure sensor 1) Temperature Sensor Arduino Mega Sound Sensor
Single Crystal Silicon Air Pressure sensor

2) ________ used to determine the distance of the object using SONAR. Ultrasoni
3) ________ allows the robots to follow a particular path specified by sensing the marking or
lines on the surface. Tracking Sensor. Tracking Sensor
4) ________ It is commonly related to meteorology, biomedical fields. It looks like the below
image:
5) ________ sensor is used to monitor weather conditions. humidity sensor
6) ________ It is commonly related to meteorology, biomedical fields Air Pressure sensor
7) ________ produces a varying voltage as the output in Arduino. humidity sensor
8) ________ are defined as a machine, module, or a device that detect changes in the
environment. sensors
9) _________ electronic devices always work together. The output signal is easily readable
by humans. sensors
10) ________ The sensor is a device, which is made up of ____________Single Crystal Sil
11) ________ is used to detect the temperature around it. Temperature Sensor
12) .________ emitting infrared radiations, which are reflected or bounced back by that object.
13) ________ LDR stands for__________.
14) ________ It is suitable for detecting the human touch. Metal Touch Sensor
15) ________It is also used to detect leaks in containers.Water Level sensors
16) ________ The vibration sensor is used to measure the vibrations.
17) ________ is suitable to detect the sound of the environment.
18) ________ The sensor in Arduino measures the pressure and displays it on the small LCD
screen. Presure senso
19) ________It is used to measure the moisture level of the soil. Capacitive soil moisture
sensor
20) ________ The analog and digital are the two outputs of this module. Mcrophone sensor

LEARNING TASK 13
(Week 8, October 25-30, 2021 Week 9 November 2-6, 2021)

Desired Learning Outcomes:

At the end of this task, the students should be able to:


1. Describe how Understand the Arduino through the serial communication where the
servo motor will be controlled.
2. Understand the Arduino through the serial communication where the servo motor
will be controlled.

PRE- ASSESSMENT 13
Answer the following questions.
1. What is Arduino Stepper Motor and how it work?
2. What is a Potentiometer ?
3. What is Arduino DC Motor?

Scoring Rubric:
Content/Idea: 5 pts
Coherence: 3 pts
Handwriting: 2 pts
------------------------------------
Total: 10 pts

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 19
CONTENT DEVELOPMENT 13
 Arduino Stepper motor

The stepper motor does not require any feedback for its operation. It can be controlled
with high accuracy due to its design.

The series of magnets mounted on the shaft of the stepper motor are controlled by the
electromagnetic coils. These coils are negatively and positively charged in a sequence,
which makes the shaft to move in forward and backward in little steps.

We can also hold the position of the motor at any step during rotation. It has a simple,
accurate open-loop system.

The Stepper is categorized into two types, which are listed below:

o Unipolar
o Bipolar

Each type possesses a different circuit, but the coding is similar.

Unipolar

The Unipolar stepper motor consists of one winding that operates with a center tap per
phase. There are three leads per phase in the motor. For the regular two-phase stepper
motor, there are six leads per phase.

The Unipolar stepper motor has five leads when both the phases are joined internally.

Bipolar

The bipolar stepper motor consists of a single winding per phase. There are two leads per
phase in the motor.

The bipolar stepper motors do not have any center tape connections. Such devices are
used when we require high torque popularly at low speeds.

How Stepper motor works?

The stepper motor can control the angular position of the rotor without a closed feedback
loop.

For example,

Consider a motor with six stator teeth and a rotor. It is shown below:

A stepper motor with six stator teeth can be triggered with three different DC power
sources. The rotor in the stepper motor is made up of a stack of steel laminations. It has
different teeth compared to the rotor, which is four.

It is done so that one pair of rotor teeth at a time can be aligned easily with the stator.

If we trigger or energize the coil A and B, the rotor would rotate. The above figure signifies
the step size is 30 degrees. We will energize coil B and C. After that, the coil A will
energize again. It means that the rotor moves to the position with the least reluctance.

The position of the rotor, when coil A is energized is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 20
The position of the rotor (moves 30 degrees), when coil B is energized is shown below:

When both the coils are excited, the position of the rotor (in between) is shown below:

The energizing of both the coils change the accuracy of the rotor from 30 degrees to 15
degrees.

The common stepper motor type is the hybrid motor type.

In this project, we will use the hybrid motor type. It looks like the image shown below:

Hardware Required

The required components are listed below:

o 1 x Arduino UNO R3 (We can use any Arduino board)


o 1 x Breadboard
o Jump Wires
o 1 x 10K Ohm Potentiometer
o 1 x Stepper motor
o 1 x power supply (according to the stepper)
o U2004 Darlington Array (For a Unipolar stepper)
o SN754410ne H-Bridge (for a bipolar stepper)

Connection diagram

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 21
We will show the connection using the Simulator so that the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

Sketch

Consider the below code:

1. #include <Stepper.h> //library declared for the operation of stepper motor


2.
3. const int stepsPERrevolution = 200; // We can change it according to the required steps
per revolution
4. // for our motor
5.
6.
7. // the initialization of pins 8 to 11 of stepper library
8. Stepper myStepper(stepsPERrevolution, 8, 9, 10, 11);
9.
10. int CountofSTEP = 0; // number of steps the motor has taken
11.
12. void setup()
13. {
14. Serial.begin(9600);
15. }
16.
17. void loop()
18. {
19. // read the sensor value:
20. int ReadingINSensor = analogRead(A1);
21. // we can map it to a range from 0 to 100:
22. int SpeedOFmotor = map(ReadingINSensor, 0, 1023, 0, 100);
23. // to set the speed of the motor
24. if (SpeedOFmotor > 0)
25. {
26. myStepper.setSpeed(SpeedOFmotor);
27. // step 1/100 of a revolution
28. myStepper.step(stepsPERrevolution/ 100);
29. }

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 22
30. }

Procedure

The steps to establish the above connection are listed below:

o Connect the negative and positive terminal of the battery to the GND and 5V pin of
the Arduino board.
o One outer pin of the potentiometer is connected to ground (GND), and the other
external pin is connected to 5V of the Arduino board.
o The middle pin of the potentiometer is connected to the analog input pin A1 of the
board.
o Connect the 8 to 11 digital pins of the Arduino board to the U2004 Darlington
Array, which is further connected to the motor.
o Connect other pins of the U2004 Darlington Array to the stepper motor, as shown
in the connection diagram.

Arduino Servo Motor

The principle of the servo motor is based on Pulse Width modulation (PWM). It means that
the duration of pulses applied to the specific control pin controls the angle of rotation of
the motor.

The construction of the servo motor is similar to a DC motor. It means that it has a rotor,
stator, and control assemblies. It has closed-loop feedback for controlling the torque and
speed.

The advantages of a servo motor are listed below:

o High efficiency
o High output power
o Small size
o Good power
o High precision
o rapid acceleration of loads

The applications of servo motors are machinery, automated manufacturing, robotics, radio
controller airplanes, etc. The controller is considered as an essential part of the servo
motor.

The movement in a servo motor is determined by an electric signal that can be either
digital or analog.

The Servo library is the library that permits the Arduino to work with servo motors.

What is the Servo library, and why is it used?

The servo library allows controlling the integrated shaft and gears. We can also position
shaft at different angles between 0 and 180 degrees. The servo library on Arduino
boards can support upto 12 motors, while on Arduino Mega board, it can support upto 48
motors.

It is because servos do not interfere with the functionality of PWM pins on the Arduino
Mega board. On other Arduino boards, the servo library disables the PWM pin 9 and 10
even if the servo is connected to these pins.

The use of motors on Mega is also limited. It means we can use 12 motors on Arduino
Mega. But, using 12 to 23 motors on the Mega board can disable the PWM functionality
on the pin number 11 and 12.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 23
What is the difference between a regular motor and a servo motor?

The difference between regular motor and servo motor are listed below:

o The output shaft of the servo motor can be moved to a specific velocity, position,
and angle while regular motors cannot.
o The feedback from the motor is used by the servo motor control loop, which helps
the motor to reach the desired velocity and position.

What is the difference between a stepper motor and a servo motor?

The difference between stepper motor and servo motor are listed below:

o The servo motor requires a control loop feedback. The control loop is used to
monitor the current distance and velocity. Due to this, it is more reliable than the
stepper motor.
o Servo motors usually have a low pole count while the stepper motors have high.
o The speed curve of the servo motor is more flexible compared to the stepper
motor.
o The stepper motor has low speed and accuracy than the servo motor.

Project

Let's start the project with Arduino.

Here, the servo motor is simply connected to the Arduino.

Hardware Required

The components required for the project are listed below:

o 1 x Mini Servo motor


o Arduino UNO R3 board (We can take any Arduino board).
o Jump wires

Mini Servo Motor: It is defined as a tiny motor that can approximately rotate upto 180
degrees. It works similar to the usual servo motor, but smaller in size.

We can also use any servo motor. The connection and procedure would be the same.

Principle

The project allows us to control the shaft at angles between 0 and 180 degrees. We can
also set the rotation of the shaft at different speeds.

Servo motor has three terminals signal, power, and ground. The signal terminal is usually
connected to the 5V pin of the Arduino board with the help of a wire.

The ground, power, and signal wire are represented by black, green, and red colors.

Structure of the project

The structure of the connection or project is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 24
Connection

The steps to set up the connection are listed below:

o Connect the signal terminal of the servo motor to the 5V pin of the Arduino board.
o Connect the power terminal of the servo motor to pin 5 of the Arduino board. We
can connect the power terminal of the motor to any digital PWM pin on the Arduino
board.
o Connect the ground terminal of the servo motor to the GND pin of the Arduino
board.

Sketch

Consider the below code:

1. #include <Servo.h>
2. int POSservo = 0;
3. Servo servo_5;
4. void setup()
5. {
6. servo_5.attach(5); // power pin connected to pin 5 of Arduino board
7. // Here, the pin of the Arduino board connected to the servo should be a PWM pin
8. }
9. void loop()
10. {
11. // It will sweep the servo from 0 to 180 degrees
12. for (POSservo = 0; POSservo <= 180; POSservo=POSservo+1)
13. {

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 25
14. // tell servo to go to position in variable 'POSservo'
15. servo_5.write(POSservo);
16. // It will wait for the specified duration (20 milliseconds) to reach the position
17. delay(20); // delay of 15 millisecond(s)
18. }
19. for (POSservo = 180; POSservo >= 0;POSservo= POSservo-1)
20. {
21. // It will tell servo to go to position in the declared variable 'POSservo'
22. servo_5.write(POSservo);
23. delay(20);
24. // we can modify the duration as per the requirements
25. }
26. }

Steps to upload the code to the project

The steps are listed below:

o Open the Arduino IDE.


o Select the type of board from Tools -> Board -> Arduino UNO.
o Select the port from Tools -> Port -> COM..
o Upload the sketch to the connection diagram.

Connection Diagram

We will show the connection using the Simulator so that the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

Output

The shaft will rotate 90 degree in each direction i.e. approx. 180 degrees.

Arduino Servomotor using Potentiometer

The Potentiometer will be used to control the position of the servo motor. The connection
will be similar to the last servo motor project, except the added Potentiometer.

Let's start with the project with Arduino.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 26
Hardware Required

The components required for the project are listed below:

o 1 x Mini Servo motor


o Arduino UNO R3 board (We can take any Arduino board).
o Jump wires
o 1 x 10K Ohm potentiometer

Mini Servo Motor: It is defined as a tiny motor that can approximately rotate up to 180
degrees. It works similar to the usual servo motor, but smaller in size.

Principle

The project allows us to control the shaft at angles between 0 and 180 degrees. We can
also set the rotation of the shaft at different speeds.

Servo motor has three terminals signal, power, and ground.

The power pin of the servo motor is connected to the PWM pin of the Arduino board.
Here, we have connected the power terminal to pin 9 of the Arduino UNO R3 board.

Structure of the project

The structure of the connection or project is shown below:

Sketch

Consider the below code:

1. #include <Servo.h>
2.
3. Servo myservo;
4. // It creates a servo object, which is used to control the servo
5.
6. int potentioPIN = A0; // specified analog pin used to connect the potentiometer

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 27
7. int value; // value initialized to the variable to read the value from the analog pin
8.
9. void setup()
10. {
11. myservo.attach(9); // servo connected to pin 9 of the Arduino board to the servo object
12. }
13.
14. void loop()
15. {
16. value = analogRead(potentioPIN);
17. // reads the value of the potentiometer (value between 0 and 1023)
18. value = map(value, 0, 1023, 0, 180);
19. // scale it to use it with the servo (value between 0 and 180)
20. myservo.write(value);
21. delay(1000); // it will wait for 1 second for the
22. // It will set the position of the motor according to the scaled value
23. value = map(value, 1023, 0, 180, 0);
24. // reads the value of the potentiometer (value between 1023 and 0)
25. myservo.write(value);
26. // scale it to use it with the servo (value between 180 and 0)
27. // the motor will rotate in reverse direction
28. delay(1000);
29. // delay time in milliseconds
30. //after 1500 millisecond it will again rotate from 0 to 180 degree
31. }

Steps to upload the code to the board

The steps are listed below:

o Open the Arduino IDE.


o Select the type of board from Tools -> Board -> Arduino UNO.
o Select the port from Tools -> Port -> COM..
o Upload the above sketch to the connection diagram.

We can also modify the code to modify the performance of the servo motor accordingly.

Connection

The steps to set up the connection are listed below:

o Connect the signal terminal of the servo motor to the 5V pin of the Arduino board.
o Connect the power terminal of the servo motor to pin 9 of the Arduino board. We
can connect the power terminal of the motor to any digital PWM pin on the Arduino
board.
o Connect the ground terminal of the servo motor to the GND pin of the Arduino
board.
o One outer pin of the Potentiometer is connected to the ground (GND), and other
external pin is connected to 5V of the Arduino board.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 28
o The middle terminal of the Potentiometer is connected to the analog input pin A0 of
the board.

Connection Diagram

We will show the connection using the Simulator so that the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

Output
The shaft will rotate at angles between 0 and 180 degrees and again in the reverse
direction.

We can also modify the code by specifying it only in one direction from 0 to 180 degrees.
Hence, we can make changes according to the requirements.

Arduino DC motor

The DC motor is considered as the simplest motor, which has various applications ranging
from households to industries. Example includes an electric window in cars, electric
vehicles, elevators, etc.

The principle of the DC motors is based on Electromagnetic Induction. It means that the
rotation of the motor depends on the force generated by the magnetic fields. It converts
electrical energy into mechanical energy. Such motors can be powered from the direct
current.

Let's discuss how the DC motor works.

Working of DC Motor

The DC motor consists of a stator, rotor, armature, and a commutator. The commutator
comes with brushes. There are two stationary magnets in the stator that are responsible
for producing the magnetic field.

The armature present in the DC motor carries the alternating current. Electrical energy is
converted into mechanical energy in the form of torque by the armature. It further transfers
this mechanical energy via shaft.

The commutator is defined as the electrical switch. It can also reverse the direction of the
current between the external circuit and the motor. The brushes act as an intermediate
between the external power supply and the rotating coils.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 29
The iron core at the center is wrapped with insulated wires concentrating on the magnetic
field when current passes through the wires. The windings of insulated wire have many
turns around the core of the motor.

The wire ends are connected to the commutator. The commutator further energizes the
armature coils and connects the power supply and the rotating coils through brushes.

Advantages of DC motors

The advantages of using DC motors are listed below:

o Low cost
o Easy motor speed control
o High reliability
o Minimal Maintenance
o High starting torque
o Quick starting
o Variable speeds
o Harmonics free

The DC motor looks like the image shown below:

Let's start with the project.

We will discuss two projects of the DC motor.

Project 1:

Here, we will discuss the simple connection of a DC motor with the


Arduino board using diode, transistor, and resistor.

Hardware Required

The components required in the project are listed below:

o Arduino UNO R3 board


o Breadboard
o A Resistor of 2.2K Ohm
o Transistor (NPN)
o Diode
o DC Motor
o Jump wires

Structure of the project

The structure of the project is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 30
Sketch

Consider the below code:

1. int PinOFmotor = 10;


2. // PIN 10 of the Arduino is initialized to the variable
3. // the pin must be a PWM pin
4. void setup()
5. {
6. pinMode(PinOFmotor, OUTPUT);
7. }
8. void loop()
9. {
10. digitalWrite(PinOFmotor, HIGH);
11. delay(1000);
12. digitalWrite(PinOFmotor, LOW);
13. delay(1000);
14. }

Steps to upload the code to the board

The steps are listed below:

o Open the Arduino IDE.


o Select the type of board from Tools -> Board -> Arduino UNO.
o Select the port from Tools -> Port -> COM.
o Upload the above sketch to the connection diagram.

Connection

The steps to set up the connection are listed below:

o Connect one end of the resistor to pin 10 (PWM) of the Arduino board.
o Connect the other end of the resistor to the middle pin of the transistor.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 31
o Connect one end terminal of the transistor to the GND pin of the Arduino and
another end terminal to the diode.
o Connect the band facing terminal of the diode to the 5V pin of the Arduino board.
o Connect one end terminal of the DC motor to band facing terminal of the diode.
o Connect another end terminal of the DC motor to the other end of the diode.

Connection Diagram

We will show the connection using the Simulator so that the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

After making connections, the motor will rotate.

Project 2:

Here, we will discuss the connection of a DC Gear motor with the Arduino board using the
L293D H-Bridge motor driver.

Let's discuss the need to use the L293D H-Bridge motor driver with the DC motor.

L293 is defined as the motor driver IC that permits the DC motor to drive in any direction.
It can also simultaneously control two DC motors. It is a 16-pin Integrated Circuit (IC).

It receives signals from the microprocessor present on the Arduino board and transmits
this signal to the motor. It has two VCC or voltage pins, where one pin draws current for its
working and another is used to provide voltage to the DC motor.

The motor usually requires high current for its operation. We can use
the microcontroller present on the Arduino, but high current might damage the
microcontroller. To overcome this, the motor driver is used.

L293D is one of the most popular motor drivers used to drive the DC motors. It can run
DC motors up to 1 Ampere current load.

The four outputs present on the L293D driver makes it suitable for driving the 4-wire
stepper motor as well. We can also drive servo motors using the L293D driver.

L293D Pinout

The pinout of L293D is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 32
Hardware Required

The components required in the project are listed below:

o Arduino UNO R3 board


o Breadboard
o DC Gear Motor
o Adjustable 30V supply
o Jump wires
o L293D H-Bridge motor driver

Sketch

Consider the below code:

1. #define MOTOR_1 11
2. // PWM pin 11
3. #define MOTOR_A 10
4. // PWM pin 10
5. // we can also connect it to the other PWM pins of the Arduino
6. #define MOTOR_B 8
7. // digital I/O pin
8.
9. #define slow 64
10. #define normal 128
11. #define fast 255
12.
13. int Speed; // initialization of speed variable
14.
15. // created functions
16. void Forward_Rev(void)
17. {
18. analogWrite(MOTOR_1, Speed);
19. digitalWrite(MOTOR_A, HIGH);
20. digitalWrite(MOTOR_B, LOW);
21. }
22. void Backward_Rev(void)
23. {
24. analogWrite(MOTOR_1, Speed);
25. digitalWrite(MOTOR_A, LOW);

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 33
26. digitalWrite(MOTOR_B, HIGH);
27. }
28.
29. void Forward_ramp_up(void)
30. {
31. digitalWrite(MOTOR_A, HIGH);
32. digitalWrite(MOTOR_B, LOW);
33. for (int i=0; i<255; i++) // loop started
34. //value set from 0 to 255
35. {
36. analogWrite(MOTOR_A, i);
37. delay(15); // delay time in milliseconds
38. }
39. }
40. void Forward_ramp_down(void)
41. {
42. digitalWrite(MOTOR_A, HIGH);
43. digitalWrite(MOTOR_B, LOW);
44.
45. for (int i=255; i>=0; i--) // loop set in reverse direction
46. // value set from 255 to 0 (reverse)
47. {
48. analogWrite(MOTOR_A, i);
49. delay(15);
50. }
51. }
52. // same statement but within different function
53. void Backward_ramp_up(void)
54. {
55. digitalWrite(MOTOR_A, LOW);
56. digitalWrite(MOTOR_B, HIGH);
57. for (int i=0; i<255; i++)
58. { analogWrite(MOTOR_A, i);
59. delay(15);
60. // we can modify the delay time as per the requirements
61. }
62. }
63. void Backward_ramp_down(void)
64. {
65. digitalWrite(MOTOR_A, LOW);
66. digitalWrite(MOTOR_B, HIGH);
67.
68. for (int i=255; i>=0; i--)
69. {
70. analogWrite(MOTOR_A, i);
71. delay(15);
72. }
73. }

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 34
74.
75. void Brake(void)
76. {
77. digitalWrite(MOTOR_A, HIGH);
78. digitalWrite(MOTOR_B, HIGH);
79. }
80.
81. void setup()
82. {
83.
84. Serial.begin(9600); // bps rate of 9600
85. Serial.println("DC motor test using L293D");
86.
87. pinMode(MOTOR_1, OUTPUT);
88. pinMode(MOTOR_A, OUTPUT);
89. pinMode(MOTOR_B, OUTPUT);
90. }
91.
92. void loop()
93. {
94.
95. Speed=slow; // Slow Speed
96. // we can modify the value as fast, slow, and normal depending on the required speed
97. //the motor will revolve according to the specified speed
98. // for example, fast will cause it to move at fast speed
99. // we can also add more parameters using #define
100.
101. Forward_Rev();
102. delay(1000);
103. Brake();
104. delay(500);
105. Backward_Rev();
106. delay(1000);
107. Brake();
108. delay(500);
109. Forward_ramp_up();
110. Forward_ramp_down();
111. Backward_ramp_up();
112. Backward_ramp_down();
113. // the statement inside the functions will run again and again
114. // the motor will revolve in forward and backward direction
115. }

Connection

The steps to set up the connection are listed below:

o Connect the red terminal of the power supply to the VCC of L293D.
o Connect the black terminal of the power supply to the GND of the L293D.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 35
o Connect both terminals of the motor to Output pin 1 and 2 of the L293D driver.
o Connect input pin 2 of L293D to the digital pin 8 of the Arduino board.
o Connect the enable pin 1 and input 1 to the PWM pin 10 and 11 of the Arduino
board.
o Connect VCC of the L293D driver to the 5V pin of the Arduino board.
o Connect GND of the L293D driver to the GND pin of the Arduino board.

Connection Diagram

We will show the connection using the Simulator so that the connections become clearer
and more precise.

We can make the same connection using the hardware devices.

The 'Slow' mode of speed will cause the motor to rotate at a slow speed. We can also
change the mode to fast or normal, as explained in the code.

We can also add more speed parameters to the code as per our requirements.

POST- ASSESSMENT 13
Write TRUE if the statement is correct. Write FALSE if the statement is incorrect and
underline the word/group of words that made the statement incorrect.

1) ________ The stepper motor can control the angular position of the rotor without a open
feedback loop.
2) _________ The principle of the servo motor is based on Pulse Width modulation (PWM).
3) ________ It is defined as a tiny motor that can approximately rotate upto 180 degrees is
mini servo motor.
4) ________ Servo motor has three terminals signal, power, and ground.
5) ________ The ground, power, and signal wire are represented by black, green, and red
colors.
6) ________ he output shaft of the servo motor can be moved to a specific velocity, position,
and angle while regular motors cannot.
7) ________ Servo motors usually have a low pole count while the stepper motors have
high.
8) .________ The speed curve of the servo motor is more flexible compared to the stepper
motor.
9) ________ The stepper motor has low speed and accuracy than the servo motor.
10) ________ The use of motors on Mega is also limited. It means we can use 12 motors on
Arduino Mega.

Scoring Rubric:
Correct answers 20 pts
------------------------------------
Total: 20 pts

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 36
LEARNING TASK 14
(Week 10 November 8-13, 2021 Week 11 November 15-20, 2021)

Desired Learning Outcomes:


At the end of this task, the students should be able to:
1. Identify and describe the categories and operating models of intrusion detection
and prevention systems
2. Understand the use of input controller device.

PRE- ASSESSMENT 14
Answer the following questions. Write your answers on a separate sheet of long bond
paper.
1. What is LED(Light Emitting Diode) Explain the importance of LED in our projects?
2. Write a simple code using Blinking an LED?

Scoring Rubric:
Content/Idea: 5 pts
Coherence: 3 pts
Handwriting: 2 pts
------------------------------------
Total: 10 pts

CONTENT DEVELOPMENT 14

Blinking an LED
It is the simple basic project created using Arduino. LED (Light Emitting Diode) is an
electronic device, which emits light when the current passes through its terminals. LED's
are used in various applications. It is also used as an ON/OFF indicator in different
electronic devices.

In this project, we will connect the LED to the digital pin on the Arduino board.
The LED will work as a simple light that can be turned ON and OFF for a
specified duration.

Structure of LED

An LED is a two-terminal device. The two terminals are called as Cathode and
Anode.
It is shown below:
The long terminal is called Anode, and the shorter terminal is called Cathode.
Here, cathode is the negative terminal and anode is the positive terminal.

Components of the project


The components used in the blinking of an LED are listed below:
1. 1 x Arduino UNO board.
We can use any version of the UNO board, such as UNO R3, etc. We can also use
other types of Arduino boards, such as Arduino Zero, Arduino Micro, etc.
2. 1 x Breadboard
3. 2 x Jump wires
4. 1 x LED
5. 1 x Resistor of 220 Ohm.
We can use a resistor of any value upto 470 Ohms. We can use other value of resistors
as well, depending on our circuit requirements. Usually,
the value should not exceed the allowable forward
current.
Structure of the project
The structure clearly shows the pinout of the UNO board.
It also displays the LED and resistance connected to the
board.
It is shown below:

Sketch
We need to install the Arduino IDE, to begin with the
coding, which is already discussed.
Open the IDE and start with the coding, which is given

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 37
below:
1. void setup ()
2. {
3. pinMode ( 8, OUTPUT); // to set the OUTPUT mode of pin number 8.
4. }
5. void loop ()
6. {
7. digitalWrite (8, HIGH);
8. delay(1000); // 1 second = 1 x 1000 milliseconds
9. digitalWrite (8, LOW);
10. delay(500); // 0.5 second = 0.5 x 1000 milliseconds
11. }
We can modify the delay duration according to our choice or as per the requirements.
Every statement of coding is explained in Arduino coding basics. You can open
the URL for clear understanding.
Note: Make sure the code is free of errors.

The sketch will be uploaded to the board after the correct compiling, as shown below:

We are required to click on the Verify button to compile the code.


The RX and TX LED on the board will light up after the successful uploading of the code.

Procedure
The procedure to join the components of the project is shown below:

Learn more

o Attach an LED on the breadboard. We need to plug-in the two terminals of an LED
into the holes of the breadboard.
We can plug-in the LED anywhere on the breadboard.

o Connect the resistor in series with the LED, as shown below:

o Connect the left leg of the resistor (connected in series with red LED) to the digital
output pin of the UNO board, i.e., PIN 8.
o Connect the negative/shorter terminal (Cathode) of the LED to the GND pin of the
UNO board using the wire, as shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 38
Here, the orange wire is connected to the PIN 8, and the blue wire is connected to the
GND.

The shorter terminal indicates the negative. So, we will connect the shorter terminal to the
Ground (GND).
o Connect the USB cable.
o Select the board and serial port in the Arduino IDE.
o Upload the sketch or code on the board.
o The LED will dim and light for the specified duration.

Important points
The important points to be considered in this project are listed below:
o The resistor must be connected in series with the LED.
The resistor prevents the excess current from reaching the LED. The excess current in the
connection can burn the LED. Hence, a resistor in series with the LED is used in the
connection.
o We can use any pin as the OUTPUT pin. For example, 8, 13, 7, 4, and 3. The
other pins are PWM and analog pins.
o One terminal of the LED is connected to the Ground while the other terminal is
connected to the digital pin. The digital pin has only two values 0 or 1.
o HIGH = 1
o LOW = 0
o Arduino UNO board is recommended for all basic projects because it is easy to
understand and implement. It is also the standard Arduino board from all types of
boards used. It supplies power and also acts as a serial port.

Blinking Two LED

We have already discussed a project of blinking an LED. Here, we will discuss a project of
blinking two LED's.

The concept of blinking two LED's is similar to the blinking of a single LED. As we know,
we can use the resistance of any value, so let's take the resistors of 470 Ohms. The
resistors reduce the amount of current reaching the LED, which saves the LED from being
burnt.

We can also use other resistors depending on the circuit limit and requirements.

Let's start with the project.

Structure of two LED's

The structure of red and green LED

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 39
is shown below:

The long terminal is called Anode (positive charged), and the short terminal is called
Cathode (negative charged).

Components

The components used in the project are listed below:

1. 1 x Arduino UNO board.


We can also use other types of Arduino boards, such as Arduino Mega, Arduino
Micro, etc.
2. 1 x Breadboard
3. 4 x Jump wires
4. 1 x Red LED
5. 1 x Green LED
We need to take 2 LEDs of any color. Here, we will use the red and green color
LED.
6. 2 x Resistor of 470 Ohm.

Structure of the project

Here, we will use the digital output pin number 13 and 7. The positive terminal of the red
LED is connected to the PIN 13, and the negative terminal (anode) is connected to the
ground.

Similarly, the positive terminal (cathode) of the green LED is connected to PIN 7 and the
negative terminal is connected to the ground.

As mentioned, two resistors each of 470 Ohms, will be connected in series to the two
LEDs in the project.

The structure will represent the pinout diagram of the project. It is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 40
Sketch

Open the Arduino IDE

(Integrated Development Environment) and start with the coding, which is given below:

1. void setup ()
2. {
3. pinMode ( 13, OUTPUT); // to set the OUTPUT mode of pin number 13.
4. pinMode ( 7, OUTPUT); // to set the OUTPUT mode of pin number 7.
5. }
6. void loop ()
7. {
8. digitalWrite (13, HIGH);
9. digitalWrite (7, LOW);
10. delay(1500); // 1.5 second = 1.5 x 1000 milliseconds
11. digitalWrite (13, LOW);
12. digitalWrite (7, HIGH);
13. delay(1000); // 1 second = 1 x 1000 milliseconds
14. }

We can modify the delay duration according to our choice or as per the requirements.

The sketch will be uploaded to the board after the correct compiling, as shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 41
Click on the Verify button present on the toolbar to compile the code.

The RX and TX LED on the board will light up after the successful uploading of the code.

Procedure

The procedure to join the components of the project is shown below:

o Plug-in the two LED adjacent to each other on the breadboard.


o Now, plug-in the resistors of 470 Ohm in series with the two LED, as shown below:

We need to check that the plug-in is performed correctly, as shown above. For any
confusion, check the pin diagram shown above in the heading-
Structure of project.

o Connect the left leg of the resistor (connected in series


with red LED) to the digital output pin of the UNO
board, i.e., PIN 13.
o Connect the left leg of the resistor (connected in series
with green LED) to the digital output pin of the UNO
board, i.e., PIN 7.
o Connect the negative/shorter terminal (Cathode) of the
red and green LED to the GND pin of the UNO board
using the wire, as shown below:

Here, the red wire is connected to the PIN 13, and the blue wire is connected to the GND.

Similarly, the green wire is connected to the PIN 7, and the orange wire is connected to
the GND.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 42
Note: The different colors of wire are used only for a better understanding.

The shorter terminal indicates the ground. So, we will connect the shorter terminal to the
Ground (GND).

o Connect the USB cable.


o Select the board and serial port in the Arduino IDE.
o Upload the sketch or code on the board.
o The LED will dim and light for the specified duration. Here, the green and red LED
will light alternatively.

It means when the red LED will be ON, the green LED will be OFF and vice versa.

Arduino Switch

Switches are used to turn ON/OFF devices and to connect different parts of a circuit. The
slide-switch in Arduino moves the slider of the switch from the open position (ON) to the
closed position (OFF).

It allows the flow of current in the circuit without the need for splice wire. The slide
switches are widely used in small circuits applications.

There are two types of circuits, which are shown below:

o Closed circuits

The closed circuits have closed loop. Electrons can easily flow in a closed circuit and light
up an LED.

o Open circuits

The open circuits have open ends, due to which electrons cannot flow through the circuit.

We can use an electronic component switch, to open and close circuits without the need
to disconnect the wires by hand again and again.

Types of Switches

There are major four types of switches in Arduino, which are listed below:

o SPST (Single Pole Single Throw) Switch

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 43
It is a switch that has one input and one output. The circuit is ON when the switch is
closed and vice versa.

o SPDT (Single Pole Double Throw) Switch

It is a three-terminal switch. It has a single input, which can switch between two outputs.

o SP3T (Single Pole Three Throw) Switch

It is a switch with one input and three outputs, where each input corresponds to any of the
output in a circuit.

o DPDT (Double Pole Double Throw) Switch

It is a switch with two inputs and four outputs. Each input of a switch in Arduino can be
connected to either of the two outputs.

where, Learn more

Pole: It signifies the number of circuits the switch can control.

Throw: It signifies the number of positions in which each pole of the switch can connect to
it.

Code Example

Let's discuss an example to light an LED using a Switch. Here, we will use the SPDT
(Single Pole Double Throw) Switch.

If we leave one side of the switch, it can work as SPST (Single Pole Single Throw) switch.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 44
Components Required

Learn more

The required components are listed below:

o Arduino UNO board. Here, we have used UNO R3.


o 1 x 220 ohm resistor
o Jump wires
o 1 x Slide switch
o 1 x green LED (we can take LED of any color)
o 1 x Breadboard

The steps for such an example are listed below:

1. Attach the green LED on the breadboard.

Learn more

2. Connect a resistor in series with the LED.

3. Attach Slide switch on the breadboard, as shown below:

4. Connect the negative pin of the LED to the Ground.

5. Connect the positive terminal of LED in series with the resistor to PIN 8.

6. Connect the common terminal or the middle terminal to pin number 3. It is because the
middle terminal is the input terminal.

7. Connect one end of slide switch to Ground and another end to 5V.

The circuit is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 45
Now, we need to write the code on the coding screen.

The code is given below:

1. const int pinOFswitch = 3;


2. const int LED = 8;
3. void setup( ) {
4. pinMode(pinOFswitch, INPUT);
5. pinMode(LED, OUTPUT);
6. }
7. void loop( )
8. {
9. int ValueOFswitch;
10. ValueOFswitch = digitalRead(pinOFswitch);
11. if (ValueOFswitch == HIGH)
12. {
13. digitalWrite(LED, HIGH);
14. delay(500);
15. }
16.
17. else
18. {
19. digitalWrite(LED, LOW);
20. delay(500);
21. }
22. }

Arduino button

The buttons are similar to switches that create and break electrical connections in the
circuits. The button plays a transition between ON and OFF state. A single press turns the
state ON, while another press turns the state OFF. It means that the button connects the
two points in a circuit when we press them.

There are two types of button, which are listed below:

o NO (Normally Open)

We mostly use NO types of buttons. In such type, the state of the button is in rest. It
means that a terminal in such a condition is not connected.

It is shown below:

Competitive questions on Structures

When we push the button, the terminals become electrically connected.

o NC (Normally Closed)

It is defined as the working state of the button. It connects the terminals of the circuit and
allows current to flow through the load.

It is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 46
NC and NO are also defined as the momentary type of switches.

Let's understand NO and NC with the help of a circuit.

The NO state of a circuit is shown below:

Due to the open ends of the circuit, the current cannot flow through it. The state of the
circuit is in rest.

The NC state of a circuit is shown below:

The current can easily flow through the circuit due to its connected ends. The LED

will be ON until we push the button again.

Another type of button is pushbutton, which is widely used in projects and circuits.

Structure of pushbutton

Let's understand the structure of pushbutton.

The pushbutton is a square shape button with four terminals, as shown below:

The two pins are next to each other on one side and another two pins on the other side.
The pins across to each other are connected. The pins next to each other can only be
connected, when we press the button.
FRELEC103 PROPERTY OF NORZAGARAY COLLEGE
ROBOTICS 47
We can also connect two opposite terminals of the pushbutton, as shown below:

Let's understand buttons with an example.

Code Example

Here, we will light an LED by pressing the pushbutton. When we press the push button, it
turns ON the LED connected to the PIN 13 on the Arduino UNO board

Components Required

The required components are listed below:

o Arduino UNO board. Here, we are using UNO R3.


o 1 x 220 ohm resistor
o 1 x 10 Kohm resistor
o Jump wires
o 1 x pushbutton
o 1 x red LED (we can take LED of any color)
o 1 x Breadboard

The steps for such an example are listed below:

1. Attach the red LED on the breadboard board.


2. Connect a resistor in series with the LED and connect it to PIN 2 of the
breadboard.
3. Connect the negative terminal of the LED to the GND pin.
4. Attach the pushbutton on the breadboard.
5. Connect a 10 kohm resistor in series with the lower right corner of the pushbutton
and connect it to the GND pin.
6. Connect the upper right corner of the pushbutton to PIN 4.
7. Connect lower left corner of the pushbutton to 5V.

The circuit is shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 48
Code

The code for the upper circuit is shown below:

1. const int ledpin = 2; // initializing pin number 2 to the LED


2. const int buttonpin = 4; // initializing pin number 4 to the button
3. int buttonState = 0;
4. void setup()
5. {
6. Serial.begin(9600);
7. pinMode(buttonpin, INPUT);
8. pinMode(ledpin, OUTPUT);
9. }
10. void loop()
11. {
12. // read the state of the pushbutton value
13. buttonState = digitalRead(buttonpin);
14. // check if pushbutton is pressed. if it is, the
15. // buttonState is HIGH
16. if (buttonState == HIGH) {
17. // turn LED on
18. digitalWrite(ledpin, HIGH);
19. Serial.println("LED is ON");
20. //When we press the button, it will print LED is ON.
21. delay ( 500);
22. }
23. else
24. {
25. // turn LED off
26. digitalWrite(ledpin, LOW);
27. Serial.println("LED is OFF"); // When we press the button, it will print LED is OFF
.
28. }
29. delay ( 500);
30. }

Output

The LED will light be OFF at the initial state.

When we continuously press the button, LED will light. The message 'LED is ON' will print
on the Serial Monitor after every 500 milliseconds.

Let's watch the output on the serial monitor.

When LED is OFF, the output appears as:

When LED is ON, the output appears as:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 49
Arduino Potentiometer

The potentiometer is a device that is used to measure the voltage or electric potential. It
provides a variable resistance when the shaft of the device is turned.
Here, we will measure the amount of resistance as an analog value produced by the
potentiometer. We will connect the potentiometer to the Arduino UNO board and will
measure the state of the potentiometer. The required code will be uploaded from our
computer to the Arduino board.

The variable resistance measured by the potentiometer can be easily read as an analog
value into the Arduino board.

What is Potentiometer?
The potentiometer is a three-terminal device. It has a rotating contact that acts as an
adjustable voltage divider.

The potentiometer structure consists of a sliding contact (called wiper), a resistive


element, electrical terminals, and a housing.
The sliding contact moves along the resistive element, while the housing consists of the
wiper and the element.

Working: The fixed input voltage is applied across the two ends terminal of a
potentiometer, which further produces the adjustable output voltage at the wiper or slider.
As the slider moves from one end to another, the divider can vary the output voltage from
maximum to Ground.
The connection of potentiometer with Arduino board is shown below:

The middle terminal of potentiometer is connected to the analog pin to read the analog
data.
Potentiometer with LED
In this example, we will use a potentiometer that controls the value at which LED blinks.
Hardware Required

Learn more
The required components are listed below:
o 1 x red LED
o Arduino UNO R3 board
o 10K Ohm Potentiometer
o Jump wires
o 220 Ohm resistor
Connection
o One outer pin of the potentiometer is connected to ground (GND), and other
external pin is connected to 5V of the Arduino board.
o The middle pin of the potentiometer is connected to the analog input pin A2 of the
board.
o The positive terminal of the LED is connected in series with 220 Ohm resistor to
pin number 13 of the board, and the negative terminal is connected to the GND.
Procedure
The analog input will turn the LED ON and OFF, which is connected to the pin number 13
of the Arduino UNO board. The time (delay time) at which LED is ON/OFF depends on the

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 50
value acquired by the analogread( ).
We have connected the potentiometer to the analog pin number 2 of the Arduino UNO
board.

When the shaft is turned, the amount of resistance on either side of the potentiometer
changes. The distance between the pin connected to 5V and GND gives the analog input.
We read input 0 when the shaft is turned in one direction, while we read input 1023 when
the shaft is turned in another direction.

In between the turning input between 0 and 1023, we get the desired value returned by
the analogRead( ). It is proportional to the voltage being applied to the pin.

Code

We will now upload the code to the board.


The code is given below:
1. int potentiometerPIN = 2;
2. // It select the input pin connected to the middle terminal of the potentiometer
3. int LEDpin = 13; // It selects the LED pin
4. int value = 0; // value initialized to store the coming value from the sensor
5. void setup()
6. {
7. pinMode(LEDpin, OUTPUT); // The LED pin is declared as the output pin
8. }
9. void loop()
10. {
11. value = analogRead(potentiometerPIN); // It reads the value from the sensor
12. digitalWrite(LEDpin, HIGH); // turn the LEDpin ON
13. delay(value); // delay time in milliseconds
14. digitalWrite(LEDpin, LOW); // turn the LEDpin OFF
15. delay(value);
16. // the delay time depends on the value stored from the sensor
17. }
Connection diagram
The connection diagram is shown below:

Arduino Simulator

The Arduino simulator is a virtual portrayal of the circuits of Arduino in the real world.
We can create many projects using a simulator without the need for any hardware.
The Simulator helps beginner and professional designers to learn, program, and create
their projects without wasting time on collecting hardware equipments.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 51
Advantages of using Simulator
There are various advantages of using simulator, which are listed below:
o It saves money, because there is no need to buy hardware equipments to make a
project.
o The task to create and learn Arduino is easy for beginners.
o We need not to worry about the damage of board and related equipments.
o No messy wire structure required.
o It helps students to eliminate their mistakes and errors using simulator.
o It supports line to line debugging, and helps to find out the errors easily.
o We can learn the code and build projects anywhere with our computer and internet
connection.
o We can also share our design with others.

Types of Simulator

There are various simulators available. Some are available for free, while some require a
license to access the simulators.
Java Try Catch
Some types of simulators are listed below:
o Autodesk Tinkercad
o Emulator Arduino Simulator
o Autodesk Eagle
o Proteus Simulator
o Virtronics Arduino Simulator
o ArduinoSim
Autodesk Eagle is an advanced simulator, which is used to design 2D and 3D models of
PCB, modular designs, multi-sheet schematics, real-time synchronization, etc.
How to access simulator?
Here, we are using the Autodesk Tinkercad Simulator.
The steps to access the TINKERCAD are listed below:
1. Open the official website of tinkercad. URL: https://www.tinkercad.com/
A window will appear, as shown below:

2. Click on the three horizontal lines present on the upper right corner.
3. Click on the 'Sign in' option, if you have an account in Autodesk. Otherwise, click on
the 'JOIN NOW' option if you don't have an account, as shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 52
The SIGN IN window will appear as:

We can select any sign-in method. Specify the username and password.
We already have an account in Autodesk, so we will sign-in directly with the username
and password.

The JOIN window will appear as:

Select the preference according to the requirements and sign-in using Gmail, etc.

4. Now, a window will appear, as shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 53
5. Click on the 'Create new circuit' option to start designing the Arduino circuit, as shown
above.
The 'Circuits' option will also show the previous circuits created by user. The design
option is used for creating the 3D design, which is of no use in Arduino.

6. We are now ready to start with the Autodesk Tinkercad. We can start creating our
projects.
Autodesk Tinkercad Simulator
It is also a simulator that is used to design virtual circuits.
Features of Tinkercad
The features of Tinkercad are listed below:
o Glow and move circuit assembly. It means we can use the components of a
circuit according to the project requirement. Glow here signifies the glowing of
LED.
o Integrated product design. It means the electronic components used in the
circuitry are real.
o Arduino Programming. We can directly write the program or code in the editor of
the simulator.
o We can also consider some ready-made examples provided by the tinkercad for
better understanding.
o Realtime simulation. We can prototype our designs within the browser before
implementing them in real-time.
How to use a simulator?
Sign-in on the Autodesk Tinkercad, as explained above. Now, follow the below steps:
o Click on 'Create new circuit' option, as shown below:

o A window will appear. We need to drag and drop the desired components in the
project screen. It is shown below:

o Click on the drop list of components and select the 'All' option.
The drop list will appear as:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 54
The selected option 'All' will display all the components and starter examples when we
scroll down a little, as shown below:

Code example to blink an LED

Let's understand with an example to blink an LED. We can use both ( blinking an LED in
basic projects and the one specified below) methods to blink an LED.
The steps are listed below:

o Search UNO R3 and drag-drop the board on the project screen. We can select any
board according to the requirements.
o Search a LED, and 1 resistor of 220 ohms and drag-drop them on the project
screen.
After selecting the resistor, a box to set the resistance will appear, as shown below:

Here, we have selected the red color for LED. We can also choose other colors.
After selecting the LED, a box to set the color will appear, as shown below:

o Now, connect the wires. For wiring, just select the point on the board to the
terminal of the component. We are not required to search for wires in the search
box.
o The circuit will now appear as:

o Select the 'Text' instead of block view, as shown below:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 55
o Click on the code button to write the code, as shown below:

o The coding screen will appear as:

It also displays the error in the code, if any.


o Click on 'Start Simulation' to upload the code on the board.

The LED will light up for 1 second and dim for 1 second.
The lighting LED is shown below:

Click on 'Stop Simulation' to stop the blinking of an LED, as shown below:

Serial Monitor
The serial monitor is present on the bottom of the coding screen.
It will look like the below image:

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 56
POST- ASSESSMENT 14
Identification: Choose the correct answers.

3 Pole 1 Switches
4 Buttons 6 potentiometer
2 DPDT 7 ground (GND)
5 Normally Open 8 Sliding wiper
10analog pin 9 three-terminal device

1) ________ used to turn ON/OFF devices and to connect different parts of a circuit.
2) ________ It is a switch with two inputs and four outputs.
3) ________ It signifies the number of circuits the switch can control.
4) ________ are similar to switches that create and break electrical connections in the
circuits.
5) ________ We mostly use NO types of buttons. In such type, the state of the button is in
rest. It means that a terminal in such a condition is not connected.
6) ________ is a device that is used to measure the voltage or electric potential. It provides a
variable resistance when the shaft of the device is turned.
7) ________ One outer pin of the potentiometer is connected to_________, and other
external pin is connected to 5V of the Arduino board.
8) ________The potentiometer structure consists of a sliding contact ________ a resistive
element, electrical terminals, and a housing.
9) _________ The potentiometer is a ___________.
10) ________ The middle terminal of potentiometer is connected to the _______to read the
analog data.

Scoring Rubric:
Content/Idea: 5pts.
Coherence: 3pts.
Handwriting: 2pts.
Total Score: 10pts.

FRELEC103 PROPERTY OF NORZAGARAY COLLEGE


ROBOTICS 57

You might also like