0% found this document useful (0 votes)
115 views

Arduino BSIT

Uploaded by

adrianonda373
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

Arduino BSIT

Uploaded by

adrianonda373
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 221

Prepared by:

Nestor R. Valdez
 A system is an arrangement where all its component
assembles work according to the specific define rules. It is a
method of organizing, working, or performing one or more
tasks according to a fixed plan.
 An embedded system is a combination of computer
software and hardware which is either fixed in
capability or programmable. An embedded system
can be either an independent system, or it can be a
part of a large system. It is mostly designed for a
specific function or functions within a larger system.
 In 1960, embedded system was first used for developing Apollo
Guidance System by Charles Stark Draper at MIT.
 In 1965, Autonetics, developed the D-17B, the computer used in
the Minuteman missile guidance system.
 In 1968, the first embedded system for a vehicle was released.
 Texas Instruments developed the first microcontroller in 1971.
 In 1987, the first embedded OS, VxWorks, was released by Wind
River.
 Microsoft's Windows embedded CE in 1996.
 By the late 1990s, the first embedded Linux system appeared.
 The embedded market reach $140 billion in 2013.
 Analysts are projecting an Embedded market larger than $40
billion by 2030.
Microprocessor (2-4GHz) Microcontroller (16-20Mhz)
 CPU is stand-alone, RAM, ROM,  CPU, RAM, ROM, I/O and timer
I/O, timer are separate are all on a single chip
 designer can decide on the  fixed amount of on-chip ROM,
amount of ROM, RAM and I/O RAM, I/O ports
ports.  for applications in which cost,
 expensive power and space are critical
 versatility  single-purpose (control-
 general-purpose oriented)
 High processing power  Low processing power
 High power consumption  Low power consumption
 Instruction sets focus on  Bit-level operations
processing-intensive operations  Instruction sets focus on control
 Typically 32/64 – bit and bit-level operations
 Typically deep pipeline (5-20  Typically 8/16 bit
stages)  Typically single-cycle/two-stage
pipeline
 What is the difference between the two?
 An Arduino is a microcontroller motherboard. A microcontroller is a simple computer that can run
one program at a time, over and over again. It is very easy to use.
 A Raspberry Pi is a general-purpose computer, usually with a Linux operating system, and the
ability to run multiple programs. It is more complicated to use than an Arduino.
 Micro – small, Controller – one that is capable of control.

 A miniaturized computer that can sense and control more of


the physical world than your average desktop.

 Control and intercepts data in forms of both input and


output.

 Receives instructions via code, executes solutions in a step-


by-step format.
 Arduino is an open-source electronics platform based on
easy-to-use hardware and software.

 Open-source physical computing platform based on a simple


microcontroller board and a development environment for
writing software for the board.

 Arduino comes with its own open-source Integrated


Development Environment (IDE) used to create programs
that the board will execute.

 Design to easily connect to your computer for easy and quick


programming and interfacing.
 An Arduino board is a one type of microcontroller based kit.
The first Arduino technology was developed in the year 2005
by David Cuartielles and Massimo Banzi.

 The designers thought to provide easy and low cost board


for students, hobbyists and professionals to build devices.

 Arduino was born at the Ivrea Interaction Design Institute


as an easy tool for fast prototyping, aimed at students
without a background in electronics and programming.
 Inexpensive - Arduino boards are relatively inexpensive compared
to other microcontroller platforms. The least expensive version of
the Arduino module can be assembled by hand, and even the pre-
assembled Arduino modules cost less than $50
 Cross-platform - The Arduino Software (IDE) runs on Windows,
Macintosh OSX, and Linux operating systems. Most
microcontroller systems are limited to Windows.
 Simple, clear programming environment - The Arduino Software
(IDE) is easy-to-use for beginners, yet flexible enough for
advanced users to take advantage of as well. For teachers, it's
conveniently based on the Processing programming environment,
so students learning to program in that environment will be
familiar with how the Arduino IDE works.
 Open source and extensible software - The Arduino software is
published as open source tools, available for extension by
experienced programmers. The language can be expanded
through C++ libraries, and people wanting to understand the
technical details can make the leap from Arduino to the AVR C
programming language on which it's based. Similarly, you can add
AVR-C code directly into your Arduino programs if you want to.
 Open source and extensible hardware - The plans of the Arduino
boards are published under a Creative Commons license, so
experienced circuit designers can make their own version of the
module, extending it and improving it. Even relatively
inexperienced users can build the breadboard version of the
module in order to understand how it works and save money.
 A typical example of the Arduino board is Arduino UNO. It
includes an Atmega328 microcontroller and it has 28-pins
 Microcontroller: ATmega328
 Operating Voltage: 5V
 Input Voltage (recommended): 7-12V
 Input Voltage (limits): 6-20V
 Digital I/O Pins(UNO): 14 (3,5,6,9,10,11) - 6 PWM pins
 Digital I/O Pins(Mega): 54 (2-13 and 44-46) - 15 PWM pins
 Analogue Input Pins: 6 (A0-A5)
 DC Current per I/O Pin: 40 mA
 DC Current for 3.3V Pin: 50 mA
 Flash Memory: 32 KB of which 0.5 KB used by bootloader
 SRAM: 2 KB (ATmega328)
 EEPROM: 1 KB (ATmega328)
 Clock Speed: 16MHz-20MHz
 Gizduino – by e-Gizmo
 Aceduino – by Alexan
 Arduino shields are modular circuit boards that piggyback
onto your Arduino to instill it with extra functionality.
 Shields are boards that can be plugged on top of the Arduino
PCB extending its capabilities.
 Connect the Arduino board to your computer using the USB
cable.
 USB type A to PC
 USB type B to Arduino
 LED power indicator should lit.
 Double click the Arduino application and wait for it to be loaded.
 It is the unit of code that is uploaded to and run on an Arduino board.
 Ex.
 Select the serial device of the Arduino board
from the Tools > Serial Port menu
 Disconnect-reconnect the USB of the Arduino
to find out which port to pick, or use the
Device Manager
 Demo
 Demo
 5mm led
 CURRENT – measure of flow of electric charges
 VOLTAGE – measure of work done in making the electric
charges flow
 RESISTANCE – property of an object to oppose the flow of
electric charges
 LOAD – any device or component that will use electrical
energy to operate.
 OHM’S LAW (V=IR)
 Voltage = Current x Resistance
 POWER EQUATION
 Power = Voltage x Current
 GND / GROUND – electronic circuit termination.
Syntax and Symbols
 Statements ignored by the Arduino when it runs
the sketch.
 Used to give information about the sketch, and
for people reading the code.
 Multi-line comment: /* <statement>
any comments
*/
 Single-line comment: //
 Place for storing a piece of data
 Has a name, value, and type
 int, char, float, byte
 Variable names may not start with a numerical
character
 Example:
 int abc = 9;
 char storeChars=‘a’;
 String x = “Word”;
 float saveDecimal;
Types
 INT
 UNSIGNED INT
 LONG
 UNSIGNED LONG
 FLOAT
 CHAR
 BYTE
 BOOLEAN
 You may now refer to this variable by its name, at
which point its value will be looked up and used

 Example:
 In a statement: digitalWrite(13, HIGH);
 Declaring: int led = 13;
 We can instead write: digitalWrite(led, HIGH);
 Modular pieces of code that perform a defined task outside
of the main program

 Very useful to reduce repetitive lines of code due to multiple


execution of commands

 Has a name, type, and value… same as variables?!


 There are two special functions that are part of
every Arduino sketch:
 setup()
▪ A function that is called once, when the sketch starts
▪ Setting pin modes or initializing libraries are placed here
 loop()
▪ A function that is called over and over and is the heart of most
sketches
 If-Else statement
 It allows you to make something happen or not
depending on whether a given condition is true or
not.
 Syntax:
 If-Else statement
 if (someCondition) {
▪ // do stuff if the condition is true
 } else if (anotherCondition) {
▪ // do stuff only if the first condition is false
▪ // and the second condition is true
}
Switch-Case statement
 Depends on whether the value of a specified variable
matches the values specified in case statements.

 Syntax:
Switch-Case Statement
 Depends on whether the value of a specified variable
matches the values specified in case statements.

 Syntax:
 While loop
 Continue program until a given condition is true

 Syntax:
 For loop
 Distinguished by a increment/decrement counter
for termination

 Syntax:
 delay()
 Halts the sequence of execution during the time
specified.

 Syntax:
▪ delay(milliseconds);
▪ milliseconds = the time value in milliseconds
 pinMode()
 Configures the specified pin to behave either as
an input or an output
 Syntax:
▪ pinMode(pin, mode);
 pin = the number label of the pin whose mode you
wish to set
 mode = either INPUT or OUTPUT
 14 configurable digital pins – can be specified to
produce an OUTPUT or expect an INPUT
 Pins are configured as INPUT by DEFAULT
 Pins labeled 0-13 can be used, note however those
with multiple use:

 0 and 1 – Serial RX and TX (permanent)


 2 and 3 – Serial RX and TX (assigned)
 3, 5, 6, 9, 10, 11 – PWM/Analog Output
 13 – Internal resistor and LED
 Low-impedance state, able to provide a maximum of 40mA
of current

 Watch out for short circuit connection and/or high current


draw!

 Good practice to always connect an external resistor before


interfacing
 No need for this on Pin 13
 Remove if maximum current draw is required
 digitalWrite()
 Command an OUTPUT pin to produce either a
HIGH or a LOW value

 Syntax:
▪ digitalWrite(pin, value);

 pin = the number label of the pin to be used.


 value = either HIGH or LOW.
 Logic ‘0’ (0V-0.8V)
 LOW value
 Represents GND or 0 volts
 Equivalent to ‘False’
 Logic ‘1’ (2V-5V)
 HIGH value
 Represents +5 volts
 Equivalent to ‘True’
 Exercise:
 Modify the Blink code to blink multiple LEDs on
different pins at the same time
 Array – a collection of variables of the same type accessed
via a numerical index
 It is a series of variable instances placed adjacent in memory,
and labeled sequentially with the index
 Exercise:
 Further modifying the code and using our new
technique, make the LEDs run! Light them one
LED at a time from left to right then right to left
on an endless loop.
Embedded System - Arduino
 Serial.begin()
 Initialize serial communication
 Commonly placed at the setup function of your sketch

 Syntax:
 Serial.begin(baud)
▪ baud: serial baud rate value to be used
▪ e.g. 300, 1200, 2400, 4800, 9600, 14400, 28800, 38400, 57600,
115200

▪ Ex. Serial.begin(14400);
 Serial.println()
 Prints data to the Serial port as ASCII text

 Syntax:
 Serial.println(val)
▪ val: the value to print, which can be any data type
▪ Ex. Serial.println(“Hello World!”);
▪ Displays Hello World! In Serial Monitor
 Serial.println(val, format)
▪ format: specifies the number base (for integral data types) or
number of decimal places (for floating point types)
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println(“Hello World!”);
delay(1000);
}
 Serial.available()
 Checks if there is data present on the line and
returns the number of bytes to be read

 Syntax:
▪ Serial.available()
▪ Ex. if (Serial.available() > 0) { …
 Serial.read()
 Returns the first byte of incoming serial data

 Syntax:
▪ variable = Serial.read();
▪ variable can be either an int or a char
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
ReceivedByte = Serial.read();
Serial.print(ReceivedByte);
delay(10);
}
}
 Front page (1 page)(1 inch)
 Objective/materials (1-2page)
 Theories and principles (1-2 page)
 Every component/device
 Data and results (2-3 page)
 Pin config / device config
 Tabled data / images / block diagrams
 Images (circuit and program)
 Schematic diagram (Fritzing/Proteus or draw)
 Observation / conclusion
 References
Technological University of the Philippines –
Taguig Campus
K14 ------------------------------------------

Course: BSES-SDP

_____________________________
Title:

Rating

Name: ______________ Date: ________


CourseYR&Sec: _______

Professor
Embedded System - Arduino
 High-impedance state, has no effect on external circuitry
and needs only very little current to sense incoming stimuli.

 Able to sink up to 40mA of current. Avoid exposing pins to


higher current values.

 Always configure with pinMode() despite having pins as


INPUT by default to ensure proper operation.
 digitalRead()
 Reads the value from a specified digital INPUT
pin, returns either HIGH or LOW

 Syntax:
▪ variable = digitalRead(pin);
▪ byte x = digitalRead(3);
 pin = the number label of the pin to be used
 variable = variable assigned to hold the read value
Pin3 Pin1

Pin4 Pin2
 Exercise:
 Connect pin 2 to the schematic as shown.
 Open the LED switch sketch and upload
to your board.
 Press and de-press the switch. What
happens?
 Exercise:
 Try to run the procedure in reverse!
What do we do to change it?
 Conditional AND
 Symbolized by &&
 Used when all conditions need to be satisfied.

 Conditional OR
 Symbolized by ||
 Used when either of the conditions need to be satisfied.

 Conditional NOT
 Symbolized by !
 Appends to other statements to invert its state
 Exercise:
 Wire up another push button
circuit. Modify the sketch so
that the LED lights up only
when both buttons are
pushed.
 Push Button Debounce and Latching
 Debounce – change state once the output is stable.
 Latch – change state and retain it until the next change
state.
 Pushbutton Debounce
and Latching
 Debounce – change
state once the output is
stable.
 Latch – change state
and retain it until the
next change state.
 Arduino Relay Module is used to control AC circuits, the relay acts as a switch that responds
to a signal received from the Arduino, it has an integrated LED that indicates if the signal is
high or low.
 Commonly used in IoT projects to control lights and other electronic appliances.

 Specifications
 The consist of a 1MΩ resistor, a LED, a 1N4007 rectifier diode and a 5VDC relay capable of handling
up to 250VAC and 10A.
 On the DC side of the board there are 3 pins for signal, power and ground. On the AC side there are 3
contacts, NC (Normally Closed), Common and NO (Normally Open).
 Connection Diagram
 For the DC part of the circuit connect S (signal) to pin 10 on the Arduino, also connect the Power line
(+) and ground (-) to +5 and GND respectively.
 On the AC side connect your feed to Common (middle contact) and use NC or NO according to your
needs.
 NO (Normally Open) will get power when (S) is high, NC (Normally Closed) gets disconnected when
(S) is high.
 Always be very careful when experimenting with AC, electrical shock can result in serious injures.
 Example Code
 The following Arduino sketch will turn the relay on/off every second. We'll connect a desk lamp to
the relay using the NO (Normally Open) connection so the lamp is off when the relay is off. Running
the sketch will cause the lamp to light up intermittently.
Embedded System - Arduino
 Arduino can “recognize” analog voltage by converting it into a digital
output.

 The Atmel chip has an onboard 6 channel, 10-bit analog-to-digital


converter.

 Analog pins also have the same functionality of general purpose


input/output (GPIO) pins.
 analogRead()
 Function to perform ADC
 Returns value from 0 to 1023 levels between 0V to 5V
 var = pot*10/1023;
 Syntax:
 variable = analogRead(A5);

 Value ‘channel’ is the label of the analog pin


used
 Connect a potentiometer to the Arduino as shown

 Open ADC sketch. Open the Serial Monitor and turn


the knob. What happens?
 Example
 Create a sketch that will BLINK an LED faster or
slower when turning the potentiometer.
 Example
 Create a sketch that controls
the intensity of an LED using
a potentiometer.

 Hint: The variable that will


change is not delay()..
 Re-maps a number from one range to another. That is, a value of fromLow would get
mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-
between, etc.
 The map() function uses integer math so will not generate fractions, when the math might
indicate that it should do so. Fractional remainders are truncated, and are not rounded or
averaged.
 Syntax
 int pot = analogRead(0);
 int var1 = map(pot, 0, 1023, 0, 255);
 int var2 = pot*255/1023;
 Parameters
 value: the number to map
 fromLow: the lower bound of the value’s current range
 fromHigh: the upper bound of the value’s current range
 toLow: the lower bound of the value’s target range
 toHigh: the upper bound of the value’s target range

 Returns
 The mapped value.
 Arduino joystick module, it uses a biaxial potentiometer to control the X
and Y axis. When pushed down, it activates a switch. Based on the PS2
controller's joystick, it's used to control a wide range of projects from RC
vehicles to color LEDs.

 Specifications
 The Joystick module consists of two 10k potentiometers perpendicularly positioned to
control the X and Y axis by changing the resistance when the joystick is moved. A push
button is activated when the joystick is pushed down the Z axis.
 Arduino joystick module, it uses a biaxial potentiometer to control the X
and Y axis. When pushed down, it activates a switch. Based on the PS2
controller's joystick, it's used to control a wide range of projects from RC
vehicles to color LEDs.
 Example Code
 The following Arduino
sketch will continually read
values from the
potentiometers and button
on the module. Moving the
joystick up/down will
increase/decrease the values
of X and moving the joystick
left/right will increase /
decrease for values of Y.
Push the joystick down to
activate the button.
 Reverse method of analog
read: from a specific value
from a range, produce the
equivalent analog voltage.

 Range: 0 – 255

 Pin is turned on and off


very fast – achieves an
“averaged” effect on the
output side
 analogWrite()
 Supported pins: 3, 5, 6, 9, 10, 11

 Syntax:
 analogWrite(pin, var1)

 Value ‘pin’ is the label of the digital pin used


 Value ‘range’ is a value between 0-255
 Active Buzzer Module Arduino module, it produces a single-tone sound
when signal is high. To produce different tones use the Passive Buzzer
module.

 Specifications
 The Active Buzzer module consists of an active piezoelectric buzzer, it
generates a sound of approximately 2.5kHz when signal is high.
 Connection Diagram
 Connect signal (S) to pin 8 on the Arduino and Ground (-) to GND. Be aware that some boards
are wrongly labeled, try inverting the cables if you can't hear any sound when running the
sketch.

 Example Code
 The following Arduino Sketch will continually turn the buzzer on and off generating a series of
short high-pitched beeps.
 Arduino Passive Piezoelectric Buzzer Module can produce a range of
sound tones depending on the input frequency.

 Specifications
 The Passive Buzzer Module consists of a passive piezoelectric buzzer, it can
generate tones between 1.5 to 2.5 kHz by switching it on and off at different
frequencies either using delays or PWM.
 Connection Diagram
 Connect signal (S) to pin 8 on the Arduino and ground (-) to GND. The middle pin is not
used.

 Example Code
 The following Arduino sketch will generate two different tones by turning on and off the
passive buzzer at different frequencies using a delay.
 Exercise:
 Connect a 4-pin RGB LED to your Arduino. Longest pin goes to +5V, as
for the other pins follow the configurations below

 Open and upload the RGB_LED sketch, what happens?

 CHALLENGE – Make a rainbow!


▪ Sweep values using PWM and produce the colors of the rainbow in
sequence
 Exercise:
 Connect a 4-pin RGB LED to your Arduino. Longest pin goes to +5V, as
for the other pins follow the configurations below

 Open and upload the RGB_LED sketch, what happens?

 CHALLENGE – Make a rainbow!


▪ Sweep values using PWM and produce the colors of the rainbow in
sequence
Arduino full color 5mm RGB LED, different colors can be obtained by
mixing the three primary colors.
 The following Arduino sketch will
gradually increase/decrease the
PWM values on the red, green
and blue pins causing the LED to
cycle through various colors.
RGB full color LED Module KY-009 for Arduino, emits a range of
colors by mixing red, green and blue. The amount of each primary
color is adjusted using PWM.

Specifications
The RGB Full Color LED SMD Module consists of a 5050 SMD LED, use with limiting resistors to
prevent burnout. Compatible with popular electronics platforms like Arduino, Raspberry Pi and
ESP8266.
 The following Arduino sketch
will cycle through various
colors by changing the PWM
value on each of the three
primary colors.
BSES-SDP-2021
 AC/DC Motors – simple to connect and use (just two leads),
driven via voltage, not very precise.

 Servo Motors – relatively simple to connect and use (three


leads), driven to a particular position or at a particular speed
via one or two control commands.

 Stepper Motors – complex to connect and use (four or more


leads), driven to a particular position via special sequencing
of control commands, can move very precise distances at
very precise speeds
DC motors
 A DC motor can run freely in both directions, but is very
difficult to control when it comes to speed or position. It’s
not easy to make it stop with exact precision. It comes with
two cables: power and ground. Note that generally, an
Arduino digital pin cannot power a DC motor.
 The cables can be connected to ground or to a digital pin.
Set the digital pin to HIGH to make it move and to LOW to
make it stop. To rotate counterclockwise, reverse the wire
connections.
 It is possible to control the speed of a DC motor using a
transistor and a technique called pulse width modulation
(PWM). With several transistors arranged on an H-bridge,
you can even control the direction without physically
changing the connections.
Servo motors

 Servo motors are often used in robotics and toys.


These are the type of motors that you are going to use
for your project because they are simple to connect
and to control from an Arduino. They have three wires:
one for power, one for ground, and one for the control
signal.

 There are two types: a standard rotation servo and a


continuous rotation servo. The standard rotation servo
can rotate 180 degrees with precision like the stepper
motors. The continuous rotation servo is similar to a DC
motor and can spin in both directions, but not as fast.
You can control both the speed and the direction
without the use of transistors.
Stepper motors
 Stepper motors can be found in electronics where high
precision is important such as scanners and printers. A
stepper motor, in contrast to the DC motor, can be very
precise with both position and speed.
 A stepper motors full rotation is divided into equally big
steps and you can control the motor to stop at each of
these steps. The steps are measured in degrees, usually 1.8,
3.6 or 7.2. The smaller the steps, the more precise. This
makes it very useful when repeated positioning is needed.
 Stepper motors will never be very fast compared to a DC
motor. It generally has 4 or more wires and usually needs
more than 5 volts to work. This means it cannot be
powered by an Arduino, but we can use an external power
supply.
 DC Motors are tricky to connect to microcontrollers!
 Needs a lot of power to run
 Produces lots of electrical noise that may interfere
with microcontroller pin outputs
 Usual and safest practice to provide separate
power source for the DC Motor
 Ensure all ground points (GND) are connected
(common)
 SPEED
 Pulse Width Modulation (PWM)

 DIRECTION
 Motor Direction follows Source Current Direction
 Needs external circuitry that will reverse the direction
of the current coming from the motor’s power supply
 Direction is binary logic!
 Numerous ways to implement this control scheme!
 Collective term – DC Motor Driver
 H-Bridge configuration is the most commonly used
and simplest to build

 L293D – Quadruple Half H-Bridge Drivers


 Single-chip solution for bi-directional control of up
to 2 DC Motors
 Internal protection circuitry and wide supply voltage
range allows easy and direct interfacing with most
microcontroller systems
 -
 DC Motor without driver.
 DC Motor with L293D driver.
 DC Motor with L293D driver.
 DC Motor without driver.
BSES-SDP-2021
 Additional sketch files composed of a series of instructions and
routines tailored specifically to interface with a certain device.
 Condenses a long and complicated sequence of instructions into a
single line command.
 Different libraries exist for different devices and modules
 Not all libraries are made to be compatible with similar modules
due to varying hardware designs and specifications.
 Libraries may conflict with other libraries due to the use of the
same interfaces
 What are Libraries?
 Libraries are a collection of code that makes it
easy for you to connect to a sensor, display,
module, etc.

 How to Install a Library


 Using the Library Manager
 Importing a .zip Library
 Manual installation
 Composed of an electric motor mechanically
linked to a potentiometer
 PWM signals are used as position commands
 3 wire interface – Power, Ground, Control
 Arduino has a standard library for servos:
 Sketch - > Import Library -> Servo

 You need to create first a Servo object using


the following command:
 Servo myservo;
 myservo is the servo object
 Attach the servo to a pin

 Syntax:
 attach(pin)
▪ Pin – the pin number that the servo is attached to

 Example:
 myservo.attach(9);
 write()
 Set the angle of the shaft to the corresponding
angle.

 Syntax:
 write(angle);
▪ angle – the value to write to the servo, from 0 to 180
▪ ex: myservo.write(180);
 A servomotor is a rotary actuator or linear actuator that allows for
precise control of angular or linear position, velocity and acceleration.
 What is so special about steppers
 A stepper motor can move in accurate, fixed
angle increments known as steps. For practical
purposes, a stepper motor is a bit like a servo: you
can tell it to move to a pre-defined position and
can count on getting fairly consistent results with
multiple repetitions.
 Servos though, are usually limited to a 0-180
degree range, while a stepper motor can rotate
continuously, similar to a regular DC motor. The
advantage of steppers over DC motors is that you
can achieve much higher precision and control
over the movement. The downside of using
steppers is that they are a bit more complex to
control than servos and DC motors.
 The 28BYJ-48 is a small, cheap, 5 volt geared stepping
motors. These stepping motors are apparently widely
used to control things like automated blinds, A/C units
and are mass produced. Due to the gear reduction ratio
of *approximately* 64:1 it offers decent torque for its
size at speeds of about 15 rotations per minute (RPM).
With some software “trickery” to accelerate gradually
and a higher voltage power source (I tested them with
12 volts DC) I was able to get about 25+ RPM. These
little steppers can be purchased together with a small
breakout board for the Arduino compatible ULN2003
stepper motor driver for less than $5. Quite a bargain,
compared to the price of a geared DC motor, a DC
motor controller and a wheel encoder! The low cost and
small size makes the 28BYJ-48 an ideal option for small
robotic applications, and an excellent introduction to
stepper motor control with Arduino. Here are the
detailed specs of the 28BYJ-48 stepper motor.
 -
BSES-SDP-2021
 A thin, flat, electronic visual display that uses the
light modulating properties of liquid crystals.

 Used in a wide range of applications, including


computers, monitors, televisions, instrument
panels, etc.

 For interfacing with Arduino system, we will use the


HD44780 Character LCD
 LCD or Liquid Crystal Display have parallel interface, meaning that
the microcontroller has to manipulate several interface pins at
once to control the display.
 Interface pins:
 1. Register select pin(RS) pin – Controls where the LCD’s memory you are
writing data to
 2. Read/Write (R/W) pin – Select reading mode or writing mode
 3. Enable pin - Enables writing to the registers.
 4. Data pins (D0 to D7) – consist of 8 data pins. The states of these pins
(high/low) are the bits that you are writing to a register when you write, or
the value s you are reading when you read.
 5. Contrast pin (Vo), - control the display contrast
 6. Power supply pins (Vcc/GND) – Power the LCD
 7. LED Backlight (Bklt+ and BKlt-) – Turns On/Off the LED backlight
 The process of controlling the LCD display involves putting
the data from the variable/image that you want to display
into the data registers, then putting instructions in the
instruction register. The LiquidCrystalDisplay Library
simplifies the process so it won’t be complicated to the user.

 The Hitachi-compatible LCD’s can be controlled in two


modes:
 4-bit mode requires seven(7) I/O pins from the Arduino
 8-bit mode requires eleven (11) I/O pins from the Arduino
 -
1. LCD RS pin to digital pin 12
2. LCD Enable pin to digital pin 11
3. LCD D4 pin to digital pin 5
4. LCD D5 pin to digital pin 4
5. LCD D6 pin to digital pin 3
6. LCD D7 pin to digital pin 2
 lcd.begin(cols,row) command set up the LCD number of columns
and rows. It specifies the dimensions (width and height of the
display).
 Ex. 16x2 LCD Display or 20x4 LCD Display
 lcd.begin(16,2) or lcd.begin(20,4)

 lcd.print(“insert your message here”) command print a string that


must have a maximum length to lcd column number.
 Ex. 16 column max length is equal with 16 and 20 column display max
length is equal with 20.

 lcd.setCursor(column,line) command that set the position of the


cursor’s line and column.
 Column – 0 to 15
 Line – 0 to 1 (16x2) or 0 to 3 (20x4)
 lcd.setCursor(0,1); set cursor to second line column 0
 Has many more specified instructions
 clear() – clears the whole display
 home() – places the cursor at the upper left corner (0,0)
 cursor(), blink(), display() – control device behavior during standby
 scrollDisplayLeft() and scrollDisplayRight() – moves the display one
space to the left/right
 autoscroll() – automatically scrolls incoming text based on text
direction
 leftToRight() and rightToLeft() – control text direction
Most common I2C addresses.
•PCF8574 = 0x20,
•PCF8574A = 0x38,
•PCF8574AT = 0x3F
•PCF8574T = 0x27
 LCD without using I2C
 (DF Robot with Keypad)

 LCD using I2C communication


 I2C scanner
 0x3F or 0x27
 Using A4 & A5 and SDA SCL
 UART – Universal Synchronous/Asynchronous
Receiver/Transmitter
 Used for communication between the Arduino board and a computer or
other devices.
 All Arduino boards have at least one serial port (also known as a UART or
USART) Serial.
 It communicates on digital pins 0 (RX) and 1 (TX) as well as with the
computer via USB. Thus, if you use these functions, you cannot also use
pins 0 and 1 for digital input or output.
 Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V
depending on the board). Don’t connect these pins directly to an RS232
serial port; they operate at +/- 12V and can damage your Arduino board.
 Data rate between two devices wanting to communicate
should be set to equal value. Maximum data rate supported
is about 230 Kbps to 460kbps.

 Type of communication
 Asynchronous

 Distance:
 Lower about 50 feet

 Pins
 TxD: Transmit Data
 RxD: Receive Data
Advantage Disadvantage
• It is simple communication and • They are suitable for communication
most popular which is available between only two devices.
due to UART support in almost
• It supports fixed data rate agreed upon
all the devices with 9 pin
between devices initially before
connector. It is also referred as
communication otherwise data will be
RS232 interface. garbled.
 To be able to upload code and access the Serial
Monitor, the UART lines (pins 0 and 1) must be
dedicated to the Arduino ONLY!
 SoftwareSerial Library enables any digital pin to
become a UART line
 ISSUES
 If running multiple lines, only ONE can receive data at
a time
 Additional burden in memory!
 Maximum data rate limit is not specified in SPI
interface. Usually supports about 10 Mbps to 20 Mbps.
 Type of communication
 Synchronous

 Distance:
 Highest

 Pins
 SCLK: Serial Clock
MOSI: Master Output, Slave Input
MISO: Master Input, Slave Output
CS/SS: Slave Select
Advantage Disadvantage
• It is simple protocol and hence so • As number of slave increases,
not require processing overheads. number of CS lines increases, this
• Supports full duplex results in hardware complexity as
communication. number of pins required will
• Due to separate use of CS lines, increase.
same kind of multiple chips can be • To add a device in SPI requires one
used in the circuit design. to add extra CS line and changes in
• SPI uses push-pull and hence software for particular device
higher data rates and longer addressing is concerned.
ranges are possible. • Master and slave relationship can
• SPI uses less power compare to not be changed as usually done in
I2C I2C interface.
• No flow control available in SPI.
 I2C supports 100 kbps, 400 kbps, 3.4 Mbps. Some
variants also supports 10 Kbps and 1 Mbps.

 Type of communication
 Synchronous

 Distance:
 Higher

 Pins
 SDA: Serial Data
SCL: Serial Clock
Advantage Disadvantage
• Due to open collector design, • Increases complexity of the circuit
limited slew rates can be achieved. when number of slaves and masters
• More than one masters can be used increases.
in the electronic circuit design. • I2C interface is half duplex.
• Needs fewer i.e. only 2 wires for • Requires software stack to control
communication. the protocol and hence it needs
• I2C addressing is simple which does some processing overheads on
not require any CS lines used in SPI microcontroller/microprocessor.
and it is easy to add extra devices on
the bus.
• It uses open collector bus concept.
Hence there is bus voltage flexibility
on the interface bus.
• Uses flow control.
 Electronic device that responds to an external
stimulus and gives off electronic signals with
respect to said stimulus.

 Can be grouped into 2 categories


 Go or No-Go Sensors - produce a binary (digital)
output, like an on or off switch.
 Analog Sensors - produce an output signal that is
proportional to its input stimulus.
 Conditioning Circuit
 additional circuitry added between the sensor and
processor to modify the sensor signal.

 Interfacing Circuit
 additional circuitry needed between the sensor
and processor to access the sensor signal.
 Light Dependent Resistor (LDR)
 A type of variable resistor whose resistance
value decreases with increasing light
intensity.

 Semiconductor material reacts with


light, allowing the device to conduct
electricity and effectively reduce its
resistance.
 Use it as a resistance element, the
varying resistance allows it to output
different voltage values.
 Follow the wiring diagram on your right,
then upload ADC sketch on your
Arduino.

 The circuit used is a simple voltage


divider circuit, the principles of which are
similar with a potentiometer.
 With the LDR input, make an LED light up
when the LDR senses darkness, and turn
off LED when LDR senses light.

 Next, make the LED adjust linearly with


the LDR input, dim the LED with respect
to the light intensity the LDR senses.
 The use of sound/vibrations as the active material in sensing.

 Ultrasonic refers to the frequency of sound that is above the human audible
range (40kHz)

 PROS: non-intrusive, no need for physical contact, able to detect objects not
applicable for vision/optics based sensors.

 CONS: very sensitive to temperature and position of operation (angles).


 HC-SR04 is a commonly used module for non-contact distance
measurement for distances from 2cm to 400cm.

 It uses sonar (like bats and dolphins) to measure distance with high
accuracy and stable readings.

 It consists of an ultrasonic transmitter, receiver and control circuit.

 The transmitter transmits short bursts which gets reflected by target and
are picked up by the receiver. The time difference between transmission
and reception of ultrasonic signals is calculated.

 Using the speed of sound and ‘Speed = Distance/Time' equation, the


distance between the source and target can be easily calculated.
 VCC connection of the sensor attached to +5V
 GND connection of the sensor attached to ground
 TRIG connection of the sensor attached to digital pin 2
 ECHO connection of the sensor attached to digital pin 4
 Sharp’s GP2Y1010AU0F is an optical air quality
sensor, designed to sense dust particles. An
infrared emitting diode and a phototransistor are
diagonally arranged into this device, to allow it to
detect the reflected light of dust in air. It is
especially effective in detecting very fine
particles like cigarette smoke, and is commonly
used in air purifier systems.
 The sensor has a very low current consumption
(20mA max, 11mA typical), and can be powered
with up to 7VDC. The output of the sensor is an
analog voltage proportional to the measured
dust density, with a sensitivity of 0.5V/0.1mg/m3.
 This dust sensor is compact in size and detects
dust in the air and also smoke particles. It
consumes low current to detect dust and uses
photometry method to detect dust level in the
Air.
Sharp pin 1 (V-LED) => 5V (connected to 150ohm resister)
Sharp pin 2 (LED-GND) => Arduino GND pin
Sharp pin 3 (LED) => Arduino pin 2
Sharp pin 4 (S-GND) => Arduino GND pin
Sharp pin 5 (Vo) => Arduino A0 pin
Sharp pin 6 (Vcc) => 5V
 RFID stands for Radio Frequency IDentification and it’s a non-contact
technology that’s broadly used in many industries for tasks such as
personnel tracking, access control, supply chain management, books
tracking in libraries, tollgate systems and so on.

 How RFID Works 0-9 A-F


 An RFID system consists of two main components, a transponder or a tag which is
located on the object that we want to be identified, and a transceiver or a reader.
 The RFID reader consist of a radio frequency module, a control unit and an
antenna coil which generates high frequency electromagnetic field.
 The tag is usually a passive component, which consist of just an antenna and an
electronic microchip, when it gets near the electromagnetic field of the
transceiver, due to induction, a voltage is generated in its antenna coil and this
voltage serves as power for the microchip.
Type of reading:
1. Load manipulation
2. Backscattered coupling
 RFID tags and readers have to be tuned to the same frequency in order to
communicate.
 There are several different frequencies an RFID system can use.
 Generally, the most common are
 Low frequency, or LF, (125 – 134 kHz)
 High frequency, or HF, (13.56 MHz)
 Ultra-high frequency, or UHF, (433, and 860-960 MHz)
 Specifications
Pin Wiring to Arduino Uno
 Input voltage: 3.3V
 Frequency: 13.56MHz SDA Digital 10
SCK Digital 13
MOSI Digital 11
MISO Digital 12
IRQ unconnected
GND GND
RST Digital 9
3.3V 3.3V
 Download the RFID library
 Unzip the RFID library
 Install the RFID library in your Arduino IDE
 Restart your Arduino IDE
 IMPORTANT: Don’t forget that the module is powered with 3.3v from
Arduino you should use a level shifter (5v to 3.3v) to avoid damaging
the component over time.
BSES-SDP-2021
BSES-SDP-2021
 IoT systems allow users to achieve deeper automation,
analysis, and integration within a system. They improve the
reach of these areas and their accuracy. IoT utilizes existing
and emerging technology for sensing, networking, and
robotics.

 IoT exploits recent advances in software, falling hardware


prices, and modern attitudes towards technology. Its new
and advanced elements bring major changes in the delivery
of products, goods, and services; and the social, economic,
and political impact of those changes.
 The most important features of IoT include artificial
intelligence, connectivity, sensors, active
engagement, and small device use. A brief review of
these features is given below:

 AI
 Connectivity
 Sensors
 Active Engagement
 Small Devices
 AI – IoT essentially makes virtually anything “smart”,
meaning it enhances every aspect of life with the power of
data collection, artificial intelligence algorithms, and
networks. This can mean something as simple as
enhancing your refrigerator and cabinets to detect when
milk and your favorite cereal run low, and to then place an
order with your preferred grocer.
 Connectivity – New enabling technologies for networking,
and specifically IoT networking, mean networks are no
longer exclusively tied to major providers. Networks can
exist on a much smaller and cheaper scale while still being
practical. IoT creates these small networks between its
system devices.
 Sensors – IoT loses its distinction without sensors. They
act as defining instruments which transform IoT from a
standard passive network of devices into an active system
capable of real-world integration.
 Active Engagement – Much of today's interaction with
connected technology happens through passive
engagement. IoT introduces a new paradigm for active
content, product, or service engagement.
 Small Devices – Devices, as predicted, have become
smaller, cheaper, and more powerful over time. IoT
exploits purpose-built small devices to deliver its
precision, scalability, and versatility.
 The advantages of IoT span across every area of lifestyle and
business. Here is a list of some of the advantages that IoT
has to offer:

 Improved Customer Engagement


 Technology Optimization
 Reduced Waste
 Enhanced Data Collection
 Though IoT delivers an impressive set of benefits, it
also presents a significant set of challenges. Here is
a list of some its major issues:

 Security
 Privacy
 Complexity
 Flexibility
 Compliance
 Security – IoT creates an ecosystem of constantly connected devices
communicating over networks. The system offers little control despite any
security measures. This leaves users exposed to various kinds of attackers.
 Privacy – The sophistication of IoT provides substantial personal data in
extreme detail without the user's active participation.
 Complexity – IoT systems are complicated in terms of design, deployment,
and maintenance given their use of multiple technologies and a large set of
new enabling technologies.
 Flexibility – Many are concerned about the flexibility of an IoT system to
integrate easily with another. They worry about finding themselves with
several conflicting or locked systems.
 Compliance – IoT, like any other technology in the realm of business, must
comply with regulations. Its complexity makes the issue of compliance seem
incredibly challenging when many consider standard software compliance a
battle.
 IoT − Sensors
 The sensing module manages sensing through assorted
active and passive measurement devices. Here is a list of
some of the measurement devices used in IoT:
Devices
accelerometers temperature sensors
magnetometers proximity sensors
gyroscopes image sensors
acoustic sensors light sensors
pressure sensors gas sensors
humidity sensors RFID sensors
 Wearable electronic devices are small devices
worn on the head, neck, arms, torso, and feet.

 Current smart wearable devices include:


 Head – Helmets, glasses
 Neck – Jewelry, collars
 Arm – Watches, wristbands, rings
 Torso – Clothing, backpacks
 Feet – Socks, shoes
 Smart watches not only help us stay connected, but
as a part of an IoT system, they allow access needed
for improved productivity.
 Smart glasses help us enjoy more of the media and
services we value, and when part of an IoT system,
they allow a new approach to productivity.
 The desktop, tablet, and cellphone remain integral parts
of IoT as the command center and remotes.

 The desktop provides the user with the highest level of control
over the system and its settings.

 The tablet provides access to the key features of the system in a


way resembling the desktop, and also acts as a remote.

 The cellphone allows some essential settings modification and


also provides remote functionality.

 Other key connected devices include standard network


devices like routers and switches.
 IoT software addresses its key areas of networking and action through
platforms, embedded systems, partner systems, and middleware. These
individual and master applications are responsible for data collection,
device integration, real-time analytics, and application and process
extension within the IoT network. They exploit integration with critical
business systems
 (e.g., ordering systems, robotics, scheduling, and more) in the execution of
related tasks.

 Data Collection
 Device Integration
 Real-Time Analytics
 Application and Process Extension
 NFC and RFID
 RFID (radio-frequency identification) and NFC (near-field
communication) provide simple, low energy, and versatile
options for identity and access tokens, connection
bootstrapping, and payments.

▪ RFID technology employs 2-way radio transmitter-receivers to


identify and track tags associated with objects.

▪ NFC consists of communication protocols for electronic devices,


typically a mobile device and a standard device.
 Low-Energy Bluetooth (BLE)
 This technology supports the low-power, long-use need of IoT function
while exploiting a standard technology with native support across
systems.

 Low-Energy Wireless
 This technology replaces the most power hungry aspect of an IoT system.
Though sensors and other elements can power down over long periods,
communication links (i.e., wireless) must remain in listening mode. Low-
energy wireless not only reduces consumption, but also extends the life of
the device through less use.

 Radio Protocols
 ZigBee, Z-Wave, and Thread are radio protocols for creating low-rate
private area networks. These technologies are low-power, but offer high
throughput unlike many similar options. This increases the power of small
local device networks without the typical costs.
 LTE-A
 LTE-A, or LTE Advanced, delivers an important upgrade to LTE
technology by increasing not only its coverage, but also
reducing its latency and raising its throughput. It gives IoT a
tremendous power through expanding its range, with its most
significant applications being vehicle, UAV, and similar
communication.

 WiFi-Direct
 WiFi-Direct eliminates the need for an access point. It allows
P2P (peer-to-peer) connections with the speed of WiFi, but with
lower latency. WiFi-Direct eliminates an element of a network
that often bogs it down, and it does not compromise on speed
or throughput.
 Engineering, Industry, and Infrastructure
 Government and Safety
 Home and Office
 Health and Medicine
 Engineering, Industry, and Infrastructure

 Applications of IoT in these areas include improving


production, marketing, service delivery, and safety. IoT
provides a strong means of monitoring various processes;
and real transparency creates greater visibility for
improvement opportunities.

 The deep level of control afforded by IoT allows rapid and


more action on those opportunities, which include events
like obvious customer needs, nonconforming product,
malfunctions in equipment, problems in the distribution
network, and more.
 Government and Safety

 IoT applied to government and safety allows improved law


enforcement, defense, city planning, and economic
management. The technology fills in the current gaps,
corrects many current flaws, and expands the reach of these
efforts. For example, IoT can help city planners have a
clearer view of the impact of their design, and governments
have a better idea of the local economy.
 Home and Office

 In our daily lives, IoT provides a personalized experience


from the home to the office to the organizations we
frequently do business with. This improves our overall
satisfaction, enhances productivity, and improves our health
and safety. For example, IoT can help us customize our office
space to optimize our work.
 Health and Medicine

 IoT pushes us towards our imagined future of medicine


which exploits a highly integrated network of sophisticated
medical devices. Today, IoT can dramatically enhance
medical research, devices, care, and emergency care. The
integration of all elements provides more accuracy, more
attention to detail, faster reactions to events, and constant
improvement while reducing the typical overhead of medical
research and organizations.
 Bluetooth is a wireless technology standard for exchanging data between fixed
and mobile devices over short distances using short-wavelength UHF radio waves
in the industrial, scientific and medical radio bands, from 2.400 to 2.485 GHz,
and building personal area networks.
 Dr. Jaap Haartsen, who invented Bluetooth while working at Ericsson in the
1990’s.

 Frequency: 2.45 GHz


 Physical range: Typically less than 10 m (33 ft), up to 100 m (330 ft); Bluetooth
5.0: 40–400 m (100–1,000 ft)
 Compatible hardware:
 Personal computers
 Smartphones
 Gaming consoles
 Audio devices
 HC-05 Bluetooth Module has 6 pins- Vcc, GND, TX, RX, Key, and
LED. It comes pre-programmed as a slave, so there is no need to
connect the Key pin, unless you need it change it to Master Mode.
 The major difference between Master and Slave modes is that, in
Slave mode the Bluetooth module cannot initiate a connection,
it can however accept incoming connections. After the
connection is established the Bluetooth module can transmit and
receive data regardless of the mode it is running in. If you are
using a phone to connect to the Bluetooth module, you can simply
use it in the Slave mode. The default data transmission rate is
9600kbps.
 The range for Bluetooth communication is usually 30m or less.
The module has a factory set pin of “1234” which is used while
pairing the module to a phone.
Pin # Pin Name Description
This pin is used to toggle between Data Mode (set low) and AT
1 Enable / Key
command mode (set high). By default it is in Data mode
2 Vcc Powers the module. Connect to +5V Supply voltage
3 Ground Ground pin of module, connect to system ground.
Transmits Serial Data. Everything received via Bluetooth will be
4 TX – Transmitter
given out by this pin as serial data.
Receive Serial Data. Every serial data given to this pin will be
5 RX – Receiver
broadcasted via Bluetooth
The state pin is connected to on board LED, it can be used as a
6 State
feedback to check if Bluetooth is working properly.
Indicates the status of Module
•Blink once in 2 sec: Module has entered Command Mode
7 LED
•Repeated Blinking: Waiting for connection in Data Mode
•Blink twice in 1 sec: Connection successful in Data Mode
Used to control the Key/Enable pin to toggle between Data and
8 Button
command Mode
 AT command mode allows you to interrogate
the Bluetooth module and to change some of
the settings; like the name, the baud rate,
whether or not it operates in slave mode or
master mode. When used as a master device
AT commands allow you to connect to other
Bluetooth slave devices.
 Bluetooth and Arduino wiring connection
 Bluetooth and Arduino wiring connection
 ZigBee is an open global standard for wireless
technology designed to use low-power digital
radio signals for personal area networks.
 Global System for Mobile Communications (GSM) is a standard
developed by the European Telecommunications Standards Institute
(ETSI) to describe the protocols for second-generation (2G) digital
cellular networks used by mobile devices such as mobile phones and
tablets.

 General Packet Radio Service (GPRS) is a packet oriented mobile data


standard on the 2G and 3G cellular communication network's global
system for mobile communications (GSM).

 SIM800L GSM/GPRS module is a miniature GSM modem


 https://lastminuteengineers.com/sim800l-
gsm-module-arduino-tutorial/
 GPS
 Global Positioning system, is a navigation technology
reliant on a satellite system based in space.
 GPS technology can pinpoint any position or address on
Earth. Though it requires multiple satellites to operate, it
can be used practically anywhere around the world,
making it extremely accessible and advantageous to
businesses with many different geographic locations.
 GPRS
 General Packet Radio Service, is the most commonly used
wireless data service.
 Older versions relied on 2G cellular networks, but now
most use 3G technology.
 GPRS enables cellular devices to perform functions such as
multimedia messaging and Internet surfing. It generally
operates on an "as used" payment model in fleet tracking.
 Pros & cons:
 As far as managing fleet operations, GPRS and
GPS tracking systems offer varied benefits.
 GPRS tracking systems are often more cost-
efficient than GPS systems.
 A GPRS vehicle tracking system only uses the
data network when data is being transmitted.
Therefore, charges apply strictly for actual
usage.
 https://en.wikipedia.org/wiki/Arduino
 http://arduinohistory.github.io/

You might also like