Arduino BSIT
Arduino BSIT
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.
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
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:
Syntax:
▪ digitalWrite(pin, value);
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
Professor
Embedded System - Arduino
High-impedance state, has no effect on external circuitry
and needs only very little current to sense incoming stimuli.
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.
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
Syntax:
analogWrite(pin, var1)
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
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.
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
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.
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.
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.
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.
It uses sonar (like bats and dolphins) to measure distance with high
accuracy and stable readings.
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.
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:
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.
The desktop provides the user with the highest level of control
over the system and its settings.
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.
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