0% found this document useful (0 votes)
57 views26 pages

Robotics Notes

Uploaded by

Nilesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views26 pages

Robotics Notes

Uploaded by

Nilesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

INTRODUCTIONS OF ROBOTICS

Robotics is a branch of science and technology that includes electronics,


mechanical and computer science and so on. This branch deals with the design,
construction, use to control robots, sensory feedback and information
processing. These are some technologies which will replace humans and human
activities in coming years. These robots are designed to be used for any purpose
but these are using in sensitive environments like bomb detection, deactivation
of various bombs etc. Robots can take any form but many of them have given
the human appearance. The robots which have taken the form of human
appearance may likely to have the walk like humans, speech, cognition and most
importantly all the things a human can do. Most of the robots of today are
inspired by nature and are known as bio-inspired robots. Robotics is that branch
of engineering that deals with conception, design, operation, and manufacturing
of robots. There was an author named Issac Asimov, he said that he was the first
person to give robotics name in a short story composed in 1940’s. In that story,
Issac suggested three principles about how to guide these types of robotic
machines. Later on, these three principles were given the name of Issac’s three
laws of Robotics. These three laws state that:
 Robots will never harm human beings.
 Robots will follow instructions given by humans with breaking law one.
 Robots will protect themselves without breaking other rules.

Definition of a Robot
• "A reprogrammable, multifunctional manipulator designed to move material,
parts, tools, or
specialized devices through various programmed motions for the performance of
a variety of tasks" .

Characteristics
There are some characteristics of robots given below:
 Appearance: Robots have a physical body. They are held by the structure of
their body and are moved by their mechanical parts. Without appearance,
robots will be just a software program.
 Brain: Another name of brain in robots is On-board control unit. Using this
robot receive information and sends commands as output. With this control
unit robot knows what to do else it’ll be just a remote-controlled machine.
 Sensors: The use of these sensors in robots is to gather info from the outside
world and send it to Brain. Basically, these sensors have circuits in them that
produces the voltage in them.
 Actuators: The robots move and the parts with the help of these robots move
is called Actuators. Some examples of actuators are motors, pumps, and
compressor etc. The brain tells these actuators when and how to respond or
move.
 Program: Robots only works or responds to the instructions which are
provided to them in the form of a program. These programs only tell the brain
when to perform which operation like when to move, produce sounds etc.
These programs only tell the robot how to use sensors data to make
decisions.
 Behaviour: Robots behavior is decided by the program which has been built
for it. Once the robot starts making the movement, one can easily tell which
kind of program is being installed inside the robot.

Scope and limitations of robots: The advance version of machines are robots
which are used to do advanced tasks and are programmed to make decisions on
their own. When a robot is designed the most important thing to be kept in mind
is that What the function is to be performed and what are the limitations of the
robot. Each robot has a basic level of complexity and each of the levels has the
scope which limits the functions that are to be performed. For general basic
robots, their complexity is decided by the number of limbs, actuators and the
sensors that are used while for advanced robots the complexity is decided by the
number of microprocessors and microcontroller used. As increasing any
component in the robot, it is increasing the scope of the robot and with every
joint added, the degree of the robot is enhanced.
Advantages: The advantages of using robots are given below:
 They can get information that a human can’t get.
 They can perform tasks without any mistakes and very efficiently and fast.

Applications: Different types of robots can performs different types of tasks. For
example, many of the robots are made for assembly work which means that they
are not relevant for any other work and these types of robots are called
Assembly Robots. Similarly, for seam welding many suppliers provide robots
with their welding materials and these types of robots are known as Welding
Robots. While on the other hand many robots are designed for heavy-duty work
and are known as Heavy Duty Robots. There are some applications given below:
 Caterpillar plans which is aiming to develop remote-controlled machines and
are expecting to develop heavy robots by 2021.
 A robot can also do Herding task.
 Robots are increasingly been used more than humans in manufacturing while
in auto-industry there are more than half of the labors are “Robots”.
 Many of the robots are used as Military Robots.
 Robots have been used in cleaning up of areas like toxic waste or industrial
wastes etc.
 Agricultural robots.
 Household robots.
 Domestic robots.
 Nano robots.
 Swarm robots.
Advantages:

1. Increased Efficiency: Robots can work 24/7 without getting tired, leading to
increased productivity and efficiency.
2. Improved Accuracy: Robots are capable of performing tasks with high
precision and accuracy, reducing errors and improving quality.
3. Increased Safety: Robots can perform tasks that are dangerous for humans,
improving overall safety in the workplace.
4. Reduced Labor Costs: The use of robots can lead to reduced labor costs, as
robots can perform tasks more cheaply than human workers.Robots are used
in different factories to produce items like plane, car parts etc.
5. Maximum robots are automatic, so they can perform different tasks without
needing human interaction.
6. They can be used for mining purposes and can be sent to earth’s madrid.

Disadvantages:

1. Initial Cost: Implementing and maintaining a robotics system can be


expensive, especially for small and medium-sized businesses.
2. Job Losses: The increased use of robots may result in job losses for human
workers, particularly in industries where manual labor is prevalent.
3. Limited Capabilities: Robots are still limited in their capabilities compared to
human workers and may not be able to perform tasks requiring dexterity or
creativity.
4. Maintenance Costs: Robots require regular maintenance and repair, which
can be time-consuming and expensive.
5. They need the power supply to keep going. People working in factories may
lose their jobs as robots can replace them.
6. They need high maintenance to keep them working all day long. And the cost
of maintaining the robots can be expensive.
7. They can store huge amount of data but they are not as efficient as our
human brains.
8. As we know that robots work on the program that has been installed in them.
So other than the program installed, robots can’t do anything different.
9. The most important disadvantage is that if the program of robots comes in
wrong hands they can cause the huge amount of destruction.

Asimov’s Laws of Robotics (1942)

• A robot may not injure a human being, or, through inaction, allow a human being
to come to harm
• A robot must obey orders given it by human beings, except where such orders
would conflict with the First Law.
• A robot must protect its own existence as long as such protection does not
conflict with the First or Second Law.

SENSORS

A sensor is defined as a device that responds to a physical stimulus (such as heat,


light, sound, pressure, magnetism, or a particular motion) and transmits a resulting
impulse (as for measurement or operating a control).

Keeping that in mind, there are many sensors for many applications. So how are
we going to distinguish them.

Types of Sensors

There are two types of sensors:

1. Direct Sensor: A sensor that can convert a non-electrical stimulus into an


electrical signal with intermediate stages. Eg: thermocouple (temperature to
voltage).
2. Indirect Sensor: A sensor that multiple conversion steps to transform the
measured signal into an electrical signal. Eg: fiber-optic displacement sensor
(light current to photons to current).

Now, remember all of the sensors can be classified mainly into these two types. But
there are other ways to classify them.

1. Active and Passive Sensors


2. Contact and Non-contact sensors
3. Absolute and Relative Sensors

Let’s get to know these types better and see what sensors fall into these
categories.

1. Active Sensor is a sensor that requires external power to operate. It is also


known as a parametric sensor i.e. output is a function of the parameter.
2. Passive Sensor is a sensor that generates its own electric signal and does
not require a power source. It is also called a self-generating sensor.
3. Contact Sensor is a sensor that requires physical contact with the stimulus.
4. Non-contact Sensor does not require physical contact with the stimulus.
5. Absolute Sensor is a sensor that reacts to a stimulus on an absolute scale.
6. Relative Sensor is the sensor where the stimulus sensed is relative to a
fixed or variable reference.
List of Sensors
Infrared Sensor (IR Sensor)

The IR sensor is an electronic device


that measures and detects infrared
radiation in its surrounding environment.
Or in simple words, it is a light-emitting
diode that can detect the change in
color, heat, and IR radiation.

Temperature Sensor

Temperature Sensors measure the


amount of heat energy or even coldness
that is generated by an object or system,
allowing us to “sense” or detect any
physical change to that temperature
producing either an analog or digital
output.

Proximity Sensor

A proximity sensor is a sensor able to


detect the presence of nearby objects
without any physical contact. A proximity
sensor often emits
an electromagnetic field or a beam
of electromagnetic radiation (infrared, for
instance), and looks for changes in
the field or return signal. The object
being sensed is often referred to as the
proximity sensor's target. Different
proximity sensor targets demand
different sensors.
Ultrasonic Sensor

An ultrasonic sensor is an electronic


device that measures the distance of a
target object by emitting ultrasonic
sound waves and converts the reflected
sound into an electrical signal.

Accelerometers

An accelerometer is a tool that


measures proper acceleration. Proper
acceleration is the acceleration (the rate
of change of velocity) of a body in its
own instantaneous rest frame; this is
different from coordinate acceleration,
which is acceleration in a
fixed coordinate system.

Pressure Sensor

A pressure sensor is a device


for pressure
measurement of gases or liquids. The
pressure is an expression of the force
required to stop a fluid from expanding
and is usually stated in terms of force
per unit area. A pressure sensor usually
acts as a transducer; it generates a
signal as a function of the pressure
imposed
Hall Effect Sensor

A Hall effect sensor is a device that is


used to measure the magnitude of a
magnetic field. Its output voltage is
directly proportional to the magnetic
field strength through it. Hall
effect sensors are used for proximity
sensing, positioning, speed detection,
and current sensing applications.

Load cell

A load cell is a type of transducer,


specifically a force transducer. It
converts a force such as tension,
compression, pressure, or torque into an
electrical signal that can be measured
and standardized. As the force applied
to the load cell increases, the electrical
signal changes proportionally.

Light Sensor

The light sensor is a passive device that


converts this “light energy” whether
visible or in the infra-red parts of the
spectrum into an electrical signal output.
Light sensors are more commonly
known as “Photoelectric Devices” or
“Photo Sensors” because the convert
light energy (photons) into electricity
(electrons).
Color Sensor

A color sensor detects the color of the


material. This sensor usually detects
color in the RBG scale. This sensor can
categorize the color as red, blue, or
green. These sensors are also equipped
with filters to reject the unwanted IR light
and UV light.
Touch Sensor

Touch Sensors are the electronic


sensors that can detect touch. They
operate as a switch when touched.
These sensors are used in lamps, touch
screens of the mobile, etc… Touch
sensors offer an intuitive user interface.

Tilt Sensor

A tilt sensor is an instrument that is used


for measuring the change in tilt and
monitoring of inclination and vertical
rotation in vertical structures. The tilt
sensor produces an electrical signal
which is proportional to the degree of tilt
in multiple axes (Uniaxial & Biaxial).

Vibration Sensor

The vibration sensor is also called


a piezoelectric sensor. These sensors
are flexible devices that are used for
measuring various processes.

Water Flow Sensor

A water flow sensor measures the rate


of flow of water and calculates the
amount of water flowed through the
pipe. The rate of flow of water is
measured as liters per hour or cubic
meters.

Heartbeat Sensor

Heartbeat Sensor is an electronic device


that is used to measure the heart rate
i.e. speed of the heartbeat.
Level Sensor

Level sensors detect the level of


liquids and other fluids and fluidized
solids,
including slurries, granular materials,
and powders that exhibit an upper free
surface.

Gas Sensor

Gas sensors (also known as gas


detectors) are electronic devices that
detect and identify different types of
gasses. They are commonly used to
detect toxic or explosive gasses and
measure gas concentration

Soil Moisture Sensor

The soil moisture sensor is a kind of


sensor used to measure the volumetric
content of water within the soil.

Rotary Encoder

A rotary encoder, also called a shaft


encoder, is an electro-
mechanical device that converts
the angular position or motion of a shaft
or axle to an analog or digital output
signals.

Tachometer

A tachometer (revolution-counter, tach,


rev-counter, RPM gauge) is an
instrument measuring the rotation speed
of a shaft or disk, as in a motor or other
machine. The device usually displays
the revolutions per minute (RPM) on a
calibrated analog dial, but digital
displays are increasingly common.
ATmega328 Arduino Uno Board Working and Its Applications

The Arduino Uno is one kind of microcontroller board based on ATmega328, and
Uno is an Italian term which means one. Arduino Uno is named for marking the
upcoming release of microcontroller board namely Arduino Uno Board 1.0. This
board includes digital I/O pins-14, a power jack, analog i/ps-6, ceramic resonator-
A16 MHz, a USB connection, an RST button, and an ICSP header. All these can
support the microcontroller for further operation by connecting this board to the
computer. The power supply of this board can be done with the help of an AC to
DC adapter, a USB cable, otherwise a battery. This article discusses what is
an Arduino Uno microcontroller, pin configuration, Arduino Uno
specifications or features, and applications.

What is Arduino Uno ATmega328?

The ATmega328 is one kind of single-chip microcontroller formed with Atmel


within the megaAVR family. The architecture of this Arduino Uno is a customized
Harvard architecture with 8 bit RISC processor core. Other boards of
Arduino Uno include Arduino Pro Mini, Arduino Nano, Arduino Due, Arduino
Mega, and Arduino Leonardo.

Arduino Uno ATmega328


Features of Arduino Uno Board

The features of Arduino Uno ATmega328 includes the following.

 The operating voltage is 5V


 The recommended input voltage will range from 7v to 12V
 The input voltage ranges from 6v to 20V
 Digital input/output pins are 14
 Analog i/p pins are 6
 DC Current for each input/output pin is 40 mA
 DC Current for 3.3V Pin is 50 mA
 Flash Memory is 32 KB
 SRAM is 2 KB
 EEPROM is 1 KB
 CLK Speed is 16 MHz

Arduino Uno Pin Diagram

The Arduino Uno board can be built with power pins, analog pins, ATmegs328,
ICSP header, Reset button, power LED, digital pins, test led 13, TX/RX pins, USB
interface, an external power supply. The Arduino UNO board description is
discussed below.

below.
Arduino Uno Board Pin Configuration

Power Supply

The Arduino Uno power supply can be done with the help of a USB cable or an
external power supply. The external power supplies mainly include AC to DC
adapter otherwise a battery. The adapter can be connected to the Arduino Uno by
plugging into the power jack of the Arduino board. Similarly, the battery leads
can be connected to the Vin pin and the GND pin of the POWER connector. The
suggested voltage range will be 7 volts to 12 volts.

Input & Output

The 14 digital pins on the Arduino Uno can be used as input & output with the help
of the functions like pinMode(), digitalWrite(), & Digital Read().

Pin1 (TX) & Pin0 (RX) (Serial): This pin is used to transmit & receive TTL serial
data, and these are connected to the ATmega8U2 USB to TTL Serial chip
equivalent pins.
Pin 2 & Pin 3 (External Interrupts): External pins can be connected to activate
an interrupt over a low value, change in value.

Pins 3, 5, 6, 9, 10, & 11 (PWM): This pin gives 8-bit PWM o/p by the function of
analogWrite().

SPI Pins (Pin-10 (SS), Pin-11 (MOSI), Pin-12 (MISO), Pin-13 (SCK): These pins
maintain SPI-communication, even though offered by the fundamental hardware,
is not presently included within the Arduino language.

Pin-13(LED): The inbuilt LED can be connected to pin-13 (digital pin). As the
HIGH-value pin, the light emitting diode is activated, whenever the pin is LOW.

Pin-4 (SDA) & Pin-5 (SCL) (I2C): It supports TWI-communication with the help of
the Wire library.

AREF (Reference Voltage): The reference voltage is for the analog i/ps with
analogReference().

Reset Pin: This pin is used for reset (RST) the microcontroller.

Memory

The memory of this Atmega328 Arduino microcontroller includes flash memory-32


KB for storing code, SRAM-2 KB EEPROM-1 KB.

Communication

The Arduino Uno ATmega328 offers UART TTL-serial communication, and it is


accessible on digital pins like TX (1) and RX (0). The software of an Arduino has a
serial monitor that permits easy data. There are two LEDs on the board like RX &
TX which will blink whenever data is being broadcasted through the USB.

A SoftwareSerial library permits for serial communication on Arduino Uno digital


pins and the ATmega328P supports TWI (I2C) as well as SPI-communication.
The Arduino software contains a wired library for simplifying the utilization of the
I2C bus.

How to Use an Arduino Uno?

Arduino Uno can detect the surroundings from the input. Here the input is a
variety of sensors and these can affect its surroundings through controlling
motors, lights, other actuators, etc. The ATmega328 microcontroller on the
Arduino board can be programmed with the help of an Arduino programming
language and the IDE (Integrated Development Environment). Arduino projects
can communicate by software while running on a PC.
Arduino Programming

Once the Arduino IDE tool is installed in the PC, attach the Arduino board to the
computer with the help of USB cable. Open the Arduino IDE & select the right
board by choosing Tools–>Board..>Arduino Uno, and select the right Port by
choosing Tools–>Port. This board can be programmed with the help of an
Arduino programming language depends on Wiring.

To activate the Arduino board & flash the LED on the board, dump the program
code with the selection of Files–> Examples..>Basics..>Flash. When the
programming codes are dumped into the IDE, and then click the button ‘upload’
on the top bar. Once this process is completed, check the LED flash on the board.

High Voltage Protection of USB

The Arduino Uno board has a rearrangeable poly fuse that defends the USB port
of the PC from the over-voltage. Though most of the PCs have their own inner
protection, the fuse gives an additional coating of safety. If above 500mA is given
to the USB port, then the fuse will routinely crack the connection until the over-
voltage is removed.

Physical Characteristics

The physical characteristics of an Arduino board mainly include length and width.
The printed circuit board of the Arduino Uno length and width are 2.7 X 2.1
inches, but the power jack and the USB connector will extend beyond the previous
measurement. The board can be attached on the surface otherwise case with the
screw holes.

Applications of Arduino Uno ATmega328

The applications of Arduino Uno include the following.

 Arduino Uno is used in Do-it-Yourself projects prototyping.


 In developing projects based on code-based control
 Development of Automation System
 Designing of basic circuit designs.
Thus, this is all about Arduino Uno datasheet. From the above information
finally, we can conclude that this is an 8-bit ATmega328P microcontroller. It has
different components like serial communication, crystal oscillator, the voltage
regulator for supporting the microcontroller. This board includes a USB
connection, digital I/O pins-14, analog i/p pins-6, a power-barrel jack, a reset
button, and an ICSP header.
Arduino Coding Basics
We have already discussed the popular Arduino Boards, Arduino IDEs, and
Installation process of the Arduino software. We learned that Arduino
IDE (Integrated Development Environment) allows us to draw the sketch and upload
it to the various Arduino boards using code. The code is written in a simple
programming language similar to C and C++.

The initial step to start with Arduino is the IDE download and installation.

Let's discuss the basics to start with Arduino programming.

Brackets
There are two types of brackets used in the Arduino coding, which are listed below:

o Parentheses ( )
o Curly Brackets { }

Parentheses ( )

The parentheses brackets are the group of the arguments, such as method,
function, or a code statement. These are also used to group the math equations.

Curly Brackets { }

The statements in the code are enclosed in the curly brackets. We always require
closed curly brackets to match the open curly bracket in the code or sketch.

Open curly bracket- ' { '

Closed curly bracket - ' } '

Line Comment
There are two types of line comments, which are listed below:

o Single line comment


o Multi-line comment

// Single line comment

The text that is written after the two forward slashes are considered as a single line
comment. The compiler ignores the code written after the two forward slashes. The
comment will not be displayed in the output. Such text is specified for a better
understanding of the code or for the explanation of any code statement.

The // (two forward slashes) are also used to ignore some extra lines of code
without deleting it.

/ * Multi - line comment */


The Multi-line comment is written to group the information for clear understanding.
It starts with the single forward slash and an asterisk symbol (/ *). It also ends with
the / *. It is commonly used to write the larger text. It is a comment, which is also
ignored by the compiler.

Coding Screen
The coding screen is divided into two blocks. The setup is considered as the
preparation block, while the loop is considered as the execution block. It is shown
below:

The set of statements in the setup and loop blocks are enclosed with the curly
brackets. We can write multiple statements depending on the coding requirements
for a particular project.

For example:

1. void setup ( )
2. {
3. Coding statement 1;
4. Coding statement 2;
5. .
6. .
7. .
8. Coding statement n;
9. }
10. void loop ( )
11. {
12. Coding statement 1;
13. Coding statement 2;
14. .
15. .
16. .
17. Coding statement n;
18. }

What is Setup? What type of code is written in the setup block?

It contains an initial part of the code to be executed. The pin modes, libraries,
variables, etc., are initialized in the setup section. It is executed only once during
the uploading of the program and after reset or power up of the Arduino board.

Zero setup () resides at the top of each sketch. As soon as the program starts
running, the code inside the curly bracket is executed in the setup and it executes
only once.

What is Loop? What type of code is written in the Loop block?

The loop contains statements that are executed repeatedly. The section of code
inside the curly brackets is repeated depending on the value of variables.

Time in Arduino
The time in Arduino programming is measured in a millisecond.

Where, 1 sec = 1000 milliseconds

We can adjust the timing according to the milliseconds.

For example, for a 5-second delay, the time displayed will be 5000 milliseconds.

Example:

Let's consider a simple LED blink example.

The steps to open such example are:

1. Click on the File button, which is present on the menu bar.


2. Click on the Examples.
3. Click on the Basics option and click on the Blink

The example will reopen in a new window, as shown below:


o The void setup () would include pinMode as the main function.

pinMode ( )
The specific pin number is set as the INPUT or OUTPUT in the pinMode () function.

The Syntax is: pinMode (pin, mode)

Where,

pin: It is the pin number. We can select the pin number according to the
requirements.

Mode: We can set the mode as INPUT or OUTPUT according to the corresponding
pin number.

Let' understand the pinMode with an example.

Example: We want to set the 12 pin number as the output pin.

Code:

1. pinMode (12, OUTPUT);

Why is it recommended to set the mode of pins as OUTPUT?

The OUTPUT mode of a specific pin number provides a considerable amount of


current to other circuits, which is enough to run a sensor or to light the LED brightly.
The output state of a pin is considered as the low-impedance state.

The high current and short circuit of a pin can damage the ATmel chip. So, it is
recommended to set the mode as OUTPUT.

Can we set the pinMode as INPUT?

The digitalWrite () will disable the LOW during the INPUT mode. The output pin will
be considered as HIGH.
We can use the INPUT mode to use the external pull-down resistor. We are required
to set the pinMode as INPUT_PULLUP. It is used to reverse the nature of the INPUT
mode.

The sufficient amount of current is provided by the pull-up mode to dimly light an
LED, which is connected to the pin in the INPUT mode. If the LED is working dimly, it
means this condition is working out.

Due to this, it is recommended to set the pin in OUTPUT mode.

o The void loop () would include digitalWrite( ) and delay ( ) as the main
function.

digitalWrite( )
The digitalWrite ( ) function is used to set the value of a pin as HIGH or LOW.

Where,

HIGH: It sets the value of the voltage. For the 5V board, it will set the value of 5V,
while for 3.3V, it will set the value of 3.3V.

LOW: It sets the value = 0 (GND).

If we do not set the pinMode as OUTPUT, the LED may light dim.

The syntax is: digitalWrite( pin, value HIGH/LOW)

pin: We can specify the pin number or the declared variable.

Let's understand with an example.

Example:

1. digitalWrite (13, HIGH);


2. digitalWrite (13, LOW);

The HIGH will ON the LED and LOW will OFF the LED connected to pin number 13.

What is the difference between digitalRead () and digitalWrite ()?

The digitalRead () function will read the HIGH/LOW value from the digital pin, and
the digitalWrite () function is used to set the HIGH/LOW value of the digital pin.

delay ( )
The delay () function is a blocking function to pause a program from doing a task
during the specified duration in milliseconds.

For example, - delay (2000)


Where, 1 sec = 1000millisecond

Hence, it will provide a delay of 2 seconds.

Code:

1. digitalWrite (13, HIGH);


2. delay (2000);
3. digitalWrite (13, LOW);
4. delay (1000);

Here, the LED connected to pin number 13 will be ON for 2 seconds and OFF for 1
second. The task will repeatedly execute as it is in the void loop ().

We can set the duration according to our choice or project requirements.

Example: To light the LED connected to pin number 13. We want to ON the LED for
4 seconds and OFF the LED for 1.5 seconds.

Code:

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

Arduino Syntax and Program Flow


Syntax
Syntax in Arduino signifies the rules need to be followed for the successful
uploading of the Arduino program to the board. The syntax of Arduino is similar to
the grammar in English. It means that the rules must be followed in order to
compile and run our code successfully. If we break those rules, our computer
program may compile and run, but with some bugs.
Let's understand with an example.

As we open the Arduino IDE, the display will look like the below image:

The two functions that encapsulate the pieces of code in the Arduino program are
shown below:

1. void setup ( )
2. void loop ( )

Functions

o The functions in Arduino combine many pieces of lines of code into one.
o The functions usually return a value after finishing execution. But here, the
function does not return any value due to the presence of void.
o The setup and loop function have void keyword present in front of their
function name.
o The multiple lines of code that a function encapsulates are written inside curly
brackets.
o Every closing curly bracket ' } ' must match the opening curly bracket '{ ' in
the code.
o We can also write our own functions, which will be discussed later in this
tutorial.

Spaces

o Arduino ignores the white spaces and tabs before the coding statements.
o The coding statements in the code are intent (empty spacing at the starting)
for the easy reading.
o In the function definition, loop, and conditional statements, 1 intent = 2
spaces.
o The compiler of Arduino also ignores the spaces in the parentheses, commas,
blank lines, etc.

Tools Tab

o The verify icon present on the tool tab only compiles the code. It is a quick
method to check that whether the syntax of our program is correct or not.
o To compile, run, and upload the code to the board, we need to click on the
Upload button.

Uses of Parentheses ( )

o It denotes the function like void setup ( ) and void loop ( ).


o The parameter's inputs to the function are enclosed within the parentheses.
o It is also used to change the order of operations in mathematical operations.

Semicolon ;

o It is the statement terminator in the C as well as C++.


o A statement is a command given to the Arduino, which instructs it to take
some kind of action. Hence, the terminator is essential to signify the end of a
statement.
o We can write one or more statements in a single line, but with semicolon
indicating the end of each statement.
o The compiler will indicate an error if a semicolon is absent in any of the
statements.
o It is recommended to write each statement with semicolon in a different line,
which makes the code easier to read.
o We are not required to place a semicolon after the curly braces of the setup
and loop function.

Arduino processes each statement sequentially. It executes one statement at a time


before moving to the next statement.

Program Flow
The program flow in Arduino is similar to the flowcharts. It represents the execution
of a program in order.

We recommend to draw the flowchart before writing the code. It helps us to


understand the concept of code, which makes it the coding simpler and easier.

Flow Charts
A flowchart uses shapes and arrows to represent the information or sequence of
actions.

An oval ellipse shows the Start of the sequence, and a square shows the action or
processes that need to be performed.

The Arduino coding process in the form of the flowchart is shown below:

Here, the processor enters our code, and the execution of code begins. After the
setup, the execution of the statement in the loop begins.

The example of the flowchart in Arduino is shown below:

#######################################################

Semester 2

NODEMCU
NodeMCU is an open-source Lua based firmware and development
board specially targeted for IoT based Applications. It includes firmware that runs
on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based
on the ESP-12 module.

NodeMCU Development Board Pinout Configuration

Pin Name Description


Category

Power Micro-USB, Micro-USB: NodeMCU can be powered through


3.3V, GND, the USB port
Vin
3.3V: Regulated 3.3V can be supplied to this pin
to power the board

GND: Ground pins


Vin: External Power Supply

Control EN, RST The pin and the button resets the microcontroller
Pins

Analog A0 Used to measure analog voltage in the range of


Pin 0-3.3V

GPIO GPIO1 to NodeMCU has 16 general purpose input-output


Pins GPIO16 pins on its board

SPI Pins SD1, CMD, NodeMCU has four pins available for SPI
SD0, CLK communication.

UART TXD0, NodeMCU has two UART interfaces, UART0


Pins RXD0, (RXD0 & TXD0) and UART1 (RXD1 & TXD1).
TXD2, UART1 is used to upload the firmware/program.
RXD2

I2C Pins NodeMCU has I2C functionality support but due


to the internal functionality of these pins, you
have to find which pin is I2C.

NodeMCU ESP8266 Specifications & Features

 Micro-controller: Tensilica 32-bit RISC CPU Xtensa LX106


 Operating Voltage: 3.3V
 Input Voltage: 7-12V
 Digital I/O Pins (DIO): 16
 Analog Input Pins (ADC): 1
 UARTs: 1
 SPIs: 1
 I2Cs: 1
 Flash Memory: 4 MB
 SRAM: 64 KB
 Clock Speed: 80 MHz
 USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
 PCB Antenna
 Small Sized module to fit smartly inside your IoT projects

PROJECTS 6th Std

 Blink LED/ 2 LED/ 3 LED and blink alternate.


 Connect DC motors to NodeMCU
 Connect LDR sensor and detect light.
 Sun tracker system.
 Detect object by Ultrasonic sound sensor.
 Water level detector system
 IR based thermometer

PROJECTS 7th Std

 Blink LED/ 2 LED/ 3 LED and blink alternate.


 Connect DC motors to NodeMCU
 Connect LDR sensor and detect light.
 Follow sunlight and move rover to sunlight.
 Dark follower rover.
 Line follower.
 Voice activated control with android and nodeMCU

PROJECTS 8th Std

 Blink LED/ 2 LED/ 3 LED and blink alternate.


 Connect DC motors to NodeMCU
 Connect LDR sensor and detect light.
 Follow sunlight and move rover to sunlight.
 Dark follower rover.
 home auto light start system.
 Weather station

PROJECTS 9th Std

 Blink LED/ 2 LED/ 3 LED and blink alternate.


 Connect DC motors to NodeMCU
 IoT home automation system.
 Humidity and temperature monitoring system
 Mobile wifi control car.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy