0% found this document useful (0 votes)
16 views22 pages

Embedded System BCA

An embedded system is a combination of hardware and software designed for specific functions, used in various devices like industrial machines, consumer electronics, and medical devices. These systems can be categorized into types such as real-time, standalone, networked, and mobile embedded systems, and consist of components like microcontrollers, memory, timers, and communication interfaces. Additionally, motors, including AC and DC types, are essential for converting electrical energy into mechanical energy, with various classifications based on their operational principles.

Uploaded by

saahu779
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)
16 views22 pages

Embedded System BCA

An embedded system is a combination of hardware and software designed for specific functions, used in various devices like industrial machines, consumer electronics, and medical devices. These systems can be categorized into types such as real-time, standalone, networked, and mobile embedded systems, and consist of components like microcontrollers, memory, timers, and communication interfaces. Additionally, motors, including AC and DC types, are essential for converting electrical energy into mechanical energy, with various classifications based on their operational principles.

Uploaded by

saahu779
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/ 22

Embedded system

An embedded system is a combination of computer hardware and software


designed for a specific function. Embedded systems might also function within a
larger system. These systems can be programmable or have a fixed functionality.
Embedded systems are used today to control numerous devices. For example,
they're used in industrial machines, consumer electronics, agricultural and
processing industry devices, automobiles, medical devices, cameras, digital
watches, household appliances, airplanes, vending machines, toys and mobile
devices.

Embedded systems typically contain a microprocessor -- or a microcontroller-based


system, memory and input/output (I/O) devices, all of which share a dedicated
function within a larger system. While embedded systems are computing systems,
they can range from having no user interface (UI) -- for example, on devices
designed to perform a single task -- to complex graphical user interfaces (GUIs),
such as in mobile devices. UIs can include buttons, light-emitting diodes (LEDs) and
touchscreen sensing. Some systems use remote user interfaces as well.

Types of embedded systems

When considering performance and functional requirements, embedded systems


are categorized into real-time embedded systems, standalone embedded
systems, networked embedded systems, and mobile embedded systems.

 Real-time embedded systems prioritize prompt output generation and


can be classified as soft real-time (lenient deadlines) or hard real-time
(strict deadlines).
 Standalone embedded systems can function independently without a
host computer.
 Networked embedded systems rely on network connections and
communication for output generation.
 Mobile embedded systems refer to small, portable devices such as
smartphones and laptops.

Components of Embedded Systems


The components of embedded systems consist of hardware and software elements
that work together to enable the desired functionality of the system.
Hardware components of embedded systems

The hardware components of embedded systems encompass various physical


elements that comprise the system infrastructure. These include power supply,
microcontrollers and microprocessors, memory, timers and counters,
communication interfaces, input/output, and electrical circuits, all of which work
together to enable the desired functionality of the embedded system.
 Power supply
The power supply component is an electrical unit responsible for powering up the
electrical load of the embedded system. While a 5V power supply is generally
required, the range can go from 1.8V to 3.3V, depending on the application.
To ensure seamless system operations, a smooth and efficient power supply is a
must. The power supply unit can either be live (such as from a wall adapter) or
battery-powered. Some embedded systems use an independent power supply, while
others leverage the same source as the larger technology being powered.
 Microcontroller and microprocessor
Embedded systems come in two key variants: microcontroller-powered and
microprocessor-powered. A form of integrated circuits, these components gives the
system its computing power. In simple terms, the microcontroller or microprocessor
serves as the brain of the embedded system and drives its performance.
Processors range from 8-bit to 16-bit to 32-bit, with the main difference in
processing speed and throughput. For instance, a 32-bit processor has a higher
processing speed since it can manipulate 32 bits at once, while a 16-bit processor
has a comparatively lower processing speed as it manipulates only 16 bits at a
time. So why don’t all embedded systems come fitted with 32-bit processors? It’s
simple. Not all applications require high processing speed and associated higher
costs!
 Memory
The memory component is essential for storing critical data in embedded systems.
This component is generally integrated into the microprocessor or microcontroller.
The two types of memory are RAM (random access memory) and ROM (read-only
memory).

RAM is also known as the ‘data memory’ and is volatile, which means that it stores
information only temporarily and is wiped clean when the power supply is turned
off. On the other hand, ROM is also known as the ‘code memory’ and is responsible
for storing the program code. It is non-volatile, storing system information even
when the power supply is turned off.
 Timer and counter
Timers are used in applications requiring the creation of a delay before the
execution of a specific function by the embedded system. On the other hand,
counters are used in applications where the number of times a specific event takes
place needs to be tracked. Up counters count upward from the starting value to
0xFF, while down counters count downward to 0x00. Counters are integrated into
the system using register-type circuits.
 Input/output
Input components allow other components within the larger interconnected
infrastructure to interact with the embedded system. For instance, a sensor helps
provide inputs for the system to process. Once processing is complete (for instance,
counting), the results are communicated to the required destination via the output
component.
 Communication interface
Communication interfaces enable embedded systems to establish communications
with each other and other components within the larger system. Different interfaces
include USB, I2C, UART, RS-485, and SPI. For simple applications, communication
ports within the microcontroller are utilized, and ports can be externally installed in
case of advanced applications.
 Electrical circuit
Depending on the application, embedded systems can contain customized electrical
circuits. Some of the basic components used in electrical circuits of embedded
systems are:
 Printed circuit board (PCB)

The PCB is a crucial component within the electrical circuit of embedded systems. It
is a mechanical circuit board that uses conductive copper traces to link other
components electronically. Electronic circuits made using a PCB are more cost-
effective and operationally efficient than wire wrap or point-to-point configurations.
 Resistor
The resistor is an electrical component primarily responsible for producing
resistance in the current flow. It reduces current flow in a calculated manner to
adjust signal levels. Motor controls and power distribution systems use high-power
resistors to dissipate more heat.
The resistor’s electrical function depends on its resistance; the greater the
resistance, the more resistance is created in the current flow. Resistors are
subdivided into fixed and variable, with fixed resistors changing their resistance
with temperature and variable resistors leveraged as sensing devices for light,
humidity, heat, and force.
 Capacitor
A capacitor is an electrical circuit component with two terminals. It is mainly used
for energy storage and release as the circuit requires. While capacitors come in
various forms, most feature two electrical conductors separated using a dielectric
material. Capacitors are used for various applications, including smoothing,
bypassing, and filtering electrical signals.
 Diode
A diode allows the current to flow in only a single direction. This component is
generally made of semiconductor materials such as silicon or germanium. It is
useful for applications such as switches, signal mixers, logic gates, voltage
regulators, limiters, clippers, gain control circuits, and clampers.
 Transistor
In the electrical circuit, transistors are responsible for switching and amplification.
They come in two main types: metal-oxide-semiconductor field-effect transistor
(MOSFET), which is a voltage-controlled component with terminals such as source,
gate, and drain; and bipolar junction transistor, which is a current-controlled
component with terminals such as base, emitter, and collector.

Transistors are used in various applications such as computers, aircraft,


pacemakers, stoves, and motor control. This component works on a simple
principle: the small current at one terminal produces a large current in the other
terminals for amplification.
 Integrated circuit
The integrated circuit combines numerous electrical components within one chip. It
helps users by providing a ready-made chip that can be directly incorporated into
the embedded system without capacitors and resistors having to be added
separately. Integrated chips can function as oscillators, microprocessors, amplifiers,
memory units, timers, and more.
 Light-emitting diode (LED)
LEDs are widely used in electrical circuits to indicate whether the circuit functions
correctly. LEDs allow users to identify the state of current within the circuit.
 Inductor
Finally, the inductor is an electrical component for energy storage in an electric field
and within the presence of an electrical current. An inductor takes the form of an
insulated wire encircling a coil. It blocks alternating current while allowing direct
current to flow. Inductors used for this function are known as ‘chokes.’
 Oscillator
Embedded systems rely on crystal oscillators to provide a stable clock signal for the
microcontroller or microprocessor. The clock signal is used to synchronize the
operations of the system, including data processing, communication, and timing of
events.

Practical Oscillator Circuit

A Practical Oscillator circuit consists of a tank circuit, a transistor amplifier, and a


feedback circuit. The following circuit diagram shows the arrangement of a practical
oscillator.
The parts of this practical oscillator circuit.

 Tank Circuit − The tank circuit consists of an inductance L connected in parallel with
capacitor C. The values of these two components determine the frequency of the
oscillator circuit and hence this is called as Frequency determining circuit.
 Transistor Amplifier − The output of the tank circuit is connected to the amplifier
circuit so that the oscillations produced by the tank circuit are amplified here.
Hence the output of these oscillations are increased by the amplifier.
 Feedback Circuit − The function of feedback circuit is to transfer a part of the
output energy to LC circuit in proper phase. This feedback is positive in oscillators
while negative in amplifiers.

The reset circuit in an embedded system is a circuit responsible for resetting the
microcontroller to its initial state. The reset circuit usually includes a reset button or
a reset pin on the microcontroller, which when triggered will cause the
microcontroller to restart its operation.

A microcontroller reset circuit usually consists of the following major components:

Reset Pin: There is usually a dedicated reset pin on the microcontroller for receiving
external reset signals. When this pin receives a reset signal, the microcontroller is
forced to restart and zero out or set its internal state to a predefined initial state.

RESET CIRCUIT: The reset circuit usually consists of a resistor, capacitor and/or
voltage regulator used to generate an appropriate reset pulse signal. This signal is
passed to the reset pin of the microcontroller to trigger a reset operation.

Reset Controller: Some microcontrollers have an internal reset controller that


monitors parameters such as supply voltage, clock, etc. to determine when to
trigger a reset operation. This prevents the microcontroller from operating
incorrectly if the supply voltage is unstable or the clock is incorrect.

Reset Vector: During a reset, the microcontroller jumps to a specific reset vector
address from where it starts executing the initialization routine. This vector address
is usually fixed and determined by the manufacturer of the microcontroller.
A microcontroller reset circuit is a very important part of a microcontroller system,
its main function is to change the power supply voltage to the microcontroller from
high to low so that the microcontroller can start working again. A microcontroller
reset circuit usually consists of a resistor and a switch. When the switch is pressed,
the resistor is energized to change the supply voltage to the microcontroller from
high to low, thus enabling the reset operation.

WDT: Watchdog timer) A watchdog timer (WDT) is a timer that monitors


microcontroller (MCU) programs to see if they are out of control or have stopped
operating. It acts as a “watchdog” watching over MCU operation. A microcontroller
(MCU) is a compact processor for controlling electronic devices.

A watchdog timer (WDT, or simply a watchdog), sometimes called a computer


operating properly timer (COP timer), is an electronic or software timer that is used
to detect and recover from computer malfunctions.[1] Watchdog timers are widely
used in computers to facilitate automatic correction of temporary hardware faults,
and to prevent errant or malevolent software from disrupting system operation.

A motor is a device that converts electrical energy to mechanical energy. There are
different types of motors based on their applications and outputs. The main
principle behind the working of any motor is the magnetic effect of an electric
current.

In this article, you will learn the working principle and applications of Ac, DC and
Special motors.

Types of Motor

Motors are classified into

1. AC motors
2. DC motors
3. Special motors

AC Motors

AC motors run on alternating current supply. It has a much wider use and
applications in the industry than DC motors. The basic parts of AC motors are a
stator and a rotor. A stator is the stationary unit of an AC motor that produces the
magnetic field required to drive the rotor while the rotor is responsible for the
delivery of rotational motion.
AC motors are majorly divided into the following categories:

1. Synchronous motors
2. Induction motors

o Synchronous Motors

In this type of motor, at a steady state, the stator moves at equal frequency with
the electric current supply and its rotational period is equal to the AC cycles. Their
rotation accuracy level is high and are generally used in automobiles, robotics and
electronics industries.

The main principle behind a synchronous motor is a 3-phase alternating supply, in


the presence of electromagnets. The rotating magnetic field produced by the stator
and the rotations of the rotor is in sync with each other. At same frequencies, the
DC supply on the flux also produces a constant magnitude.

o Induction Motors

Induction motors are also known as asynchronous AC motors. The electric current in
the rotor that produces torque is obtained by electromagnetic induction from the
magnetic field of the rotor. There are two types of induction motors – single-phase
induction and three-phase induction
Speaking of the working principle of induction motors, a double excitation is
required to make the DC motor rotate. According to Faraday’s law of
electromagnetic induction, the rotor winding is arranged in such a way that a short
circuit is produced via brush arrangement. The stator is of such type that it reduces
the loss of eddy current or any hysteresis losses. The rotor flux lags with respect to
the stator flux and torque will be required to make the magnetic field rotate in the
direction of the electric field and this is the working principle of both single and
three-phase induction motors.

The above diagram shows a single phase induction motor

Single-phase induction motors are generally preferred over domestic households


than industries. The stators are provided with concentric coils but here the rotor is a
squirrel cage rotor type. It is not a self-starting motor.

Three-phase induction motors are self-starting motors. It starts running


automatically without the need of any external force because in this motor circuit
there are 3 single phase lines with a 120-degree phase difference
DC Motors

Any motor that converts direct current and converts into electrical energy is known
as a DC motor. Most DC motors already have an internal mechanism. The main
working principle of a DC motor is Fleming’s left-hand rule. It states that if a current
carrying conductor is placed in a magnetic field, it will experience torque and
eventually move, which is also known as the motoring action. The direction of
rotation depends on the direction of the current. Therefore, if the direction of
current reverses so does the rotation of the motor.

Above is the basic conceptual diagram of a DC motor

There are various types of DC motors which are as follows

1. DC shunt motor
2. Separately excited motor
3. DC series motor
4. PMDC motor
5. DC compound motor
6. Brushed motor
Let’s summarize the types of DC motors

1. DC shunt motor – It falls under the category of self-excited DC motors. The


field windings are connected in parallel to the armature windings of the motor
and hence both the armature winding as well as the field winding are
exposed to the supply voltage despite having a separate flow of branches.
They maintain a constant speed, despite the changing nature of the load
2. Separately excited motor – In this type of DC motor, a separate supply is
used to excite both the armature coil and the field coil. Unlike the DC shunt
motor which has the same supply for both and the armature, the current
does not move across the field winding because it is powered from an
external source supply
3. DC series motor – Unlike the DC shunt motor, the field windings and the
armature coil are connected in series. Since they have the capacity to run
through both AC and DC currents, they are also known as universal motors.
The speed of a DC series motor always depends on the load. The direction of
the rotor can be changed simply by interchanging the connections with
respect to the armature
4. PMDC motor – PMDC stands for permanent magnet DC motor. It is inbuilt with
a permanent magnet to create the magnetic field necessary for the operation
of the motor. Here, the permanent magnetic field created communicates with
the perpendicular field stimulated by the flow of current and cause a torque
reaction on the rotor
5. DC compound motor – It is a hybrid of DC shunt motor and DC series motor.
Here, the armature windings are connected in series whereas the field coils
are connected either in series or parallel. They are further subdivided into –
short shunt, long shunt, cumulative motors and differential motors.
6. Brushed motor – It’s one of the simplest types of DC motor that uses a brush
to deliver through motor windings via mechanical commutation. The number
of wounds of coils and their density determine the property of a brushed
motor. Here, the electricity flows through the armature by the brushes
located on the opposite side of the shaft
Special Motors

Special motors refer to the term where any motor other than the general purpose
motor has its special operating capacity by customisation or manual design. There a
various types of special motors , which are as follows :

1. Stepper motor
2. Brushless DC motors
3. Universal motor

1. Stepper motor – It offers angle step revolution than that of a stable revolution
and its revolution angle is 180 degrees. But in the total revolution cycle, the
stepper motor goes through stepwise motion, every eighteen times per 10
degrees. It is a brushless synchronous type of electric motor , the working
principle of a stepper motor is closely related to that of a switched reversed
motor, here the rotation is purely controlled by the number of pulses received
2. Brushless DC motor – In this type of motor, the coils are not placed on the
rotor. Instead, the rotor itself is a permanent magnet. The rotation is
achieved by changing the direction of the magnetic field by stationary coils.
To control the rotation, only the magnitude of and direction of the current
moving in these coils needs to be controlled.
3. Universal motor – Its working principle is identical to the DC series motor.
They are known as universal motors because they have the capacity to
operate in both AC and DCsupplies.

Application of Motors
Following are the applications of motors.

1. Due to its low commercial costs, DC motors are generally preferred in


domestic households
2. It eliminates the labor costs required due to its high efficiency working on
higher loads, especially in the manufacturing of automobiles and robotics
3. Electric motors are one of the primary components for heating, ventilating
and cooling types of equipment.
4. Synchronous motors are generally seen in the positioning system and watch
due to its high precision. They are also found in rolling mills due to their
power factor improvement
5. Universal motors are generally used in blow dryers, drill machines etc where
high speed and light weight are desirable
6. They also operate in quiet working conditions, producing less noise, ideal for
hospital or academic environments.

These applications mentioned above are a few of the many uses of motors. Overall,
they show a wide range of different power and lengths, depending on the type of
motor and the requirement.

Pulse width modulation (PWM) is a modulation technique that generates variable-


width pulses to represent the amplitude of an analog input signal.

An H-bridge is built of four switches that control the flow of current to a load. In the
image above, the load is the M connecting the two sets of switches. Using one
current source, you can drive current in two directions by closing two switches.

If Switch 1 and 4 are closed, then the current will flow from the left to right on this
image:
The H-bridge configured to have switch 1 and switch 4 closed.

If you close switch 1 and switch 4, the current will flow from the source, through
switch 1, and then through the load, then through switch 4, and then back to the
load.

An H-bridge circuit with S2 and S3 closed.

In the image above, the circuit has Switch 2 and switch 3 closed. This will cause the
current to flow from the source, through switch 3, and then through the load, then
through switch 2, then back to the load.
One thing you have to be very cautious about when working with H-bridges is to not
create a short circuit. If you create a short circuit, that’s a sure way to burn out your
H-bridge. I may have burned out my very first H-bridge at Digilent. Good thing I
learned that lesson for all of you!

If you drive current and close two switches in series, for example, switch 3 and 4 in
the image below, you will cause a short and burn out the H-bridge. As they say,
don’t burn bridges!

This was an H-bridge.

So an H-bridge is just a way to control current direction with switches, but why is
this useful?

The most typical application of an H-bridge circuit is motor control. Be warned, if


you drive the motor and change direction at the same time, you will burn out the H-
bridge circuit. Just remember where there’s direction and current, there’s H-bridges
burnt.
Digilent offers 3 Peripheral Modules (Pmods) with H-bridge circuits for motor control.
These include the Pmod HB5 for controlling 1 DC motor connected with a 6 pin
connector, the Pmod HB3 for controlling 1 DC motor connected by screw terminals,
and the Pmod DHB1 for controlling 2 DC motors or 1 stepper motor.

What is Arduino?
With the increasing demand for programming, there was a need for a device that
could program electrical devices therefore, Arduino was introduced. Arduino is a
board made up of several interconnected components like microcontrollers, digital
pins, analog pins, power supplies, and crystal oscillators which give Arduino the
ability to program electronic instruments. You must be familiar with the idea that
an Arduino board can be programmed to illuminate an LED. The Arduino has its
hardware and software using which it can program devices. Let us take a look at
the Arduino board.
Arduino Board

 Microcontroller: The microcontroller used on the Arduino board is essentially


used for controlling all major operations. The microcontroller is used to
coordinate the input taken and execute the code written in a high-level
language.
 Analog Reference pin: Analog pins are used for general purposes like
supporting 10-bit analog-to-digital conversion (ADC) which is performed using
analog the Read() function. Analog pins are particularly helpful since they can
store 0-255 bits which is not possible using digital pins.
 Digital Pins: Digital pins are used for general purposes like taking input or
generating output. The commands that are used for setting the modes of the
pins are pinMode(), digitalRead(), and digitalWrite() commands.
 Reset Button: The reset button on the Arduino board is used for setting all the
components of Arduino to their default values. In case you want to stop the
Arduino in between you can use this reset button.
 Power and Ground Pins: As the name suggests, power and ground pins are
used to supply the power needed for driving the Arduino board. The ground
pins are usually 0V to set a reference level for the circuit.
 USB (universal serial bus): The Arduino needs certain protocols for
communication purposes and the universal serial bus is used for this purpose.
It helps to connect Arduino, microcontrollers with other raspberry pies.
Electronic Signals
Let us study the two types of signals that are used for communication:
Analog Signal: Analog signals can take any value in a given continuous range of
values. Generally, analog signals used in Arduino are around 0V to 5V. The analog
pins can take data up to 8-bit resolution therefore, they are used for taking large
values as input in the Arduino. These signals carry data in a very accurate form
without many errors.
Digital Signal: Digital signals can only take discrete values which are, high('1') and
low('0'). These signals are usually used to Arduino on or off which requires only
two values. The collection of two values (0 and 1) can be used to generate a
sequence known as the binary sequence which is a collection of zeroes and ones.
This is how data is transmitted without much memory requirement but this can
lead to certain errors like quantization errors.

Brackets
There are two types of brackets utilized in Arduino coding, as given below:
 Parentheses: When writing a function in IDE, the parentheses brackets are used
to include the argument parameters, such as methods, functions, or code
statements. In addition to this, the bracket is also used for defining the
precedence order while dealing with mathematical equations. These brackets
are represented by '( )'.
 Curly Brackets: Curly brackets are used to open and close all the statements in
the functions or out of the functions. Note that a closed curly bracket always
follows the open curly bracket in the code for proper layout. These brackets are
denoted by '{ }'.
o Open curly bracket- ' { '
o Closed curly bracket - ' } '

Line Comment
There are two types of line comments, let us study them individually:
 Single-line comment: As the name suggests, the single lines that follow two
forward slashes are known as single-line comments. These statements are
known as comments because the compiler ignores all the characters that come
after two forward slashes in a single line. Comments are hidden when the
output is presented. Comments are added for the sole purpose of
comprehension of the code and for writing necessary information for user
reference.
// This is a comment
 Multi-line comment: The single line comment extends to one line and the Multi-
line comment is used for adding comments in multiple lines. The syntax is a
forward slash followed by an asterisk symbol (/*), ending with a */. It is mostly
used for commenting larger text blocks that are not interpreted by the compiler
and solely for reference purposes of users.
/ * This is a multiline comment*/

Coding Screen
If you open the coding screen of your IDE, you will realize that it is divided into two
sections namely, setup() and loop(). The setup segment is the first block and is
implemented first for preparing the necessary environment needed for running
other commands. This coding screen is shown below:

Co
ding Screen Image Credit-Arduino IDE:https://www.arduino.cc/en/software

It is important to note that the setup and loop blocks must have statements that
are enclosed within curly brackets. Depending on the type of project you are
working on, you can initialize the setup in setup() and define other necessary
statements in the loop() block. Let us study each section individually
For example
void setup ( ) {
Coding statement 1;
Coding statement 2;
Coding statement n;
}
void loop ( ) {
Coding statement 1;
Coding statement 2;
Coding statement n;
}
Setup

Setup contains the very beginning section of the code that must be executed first.
The pin modes, libraries, variables, etc., are included in the setup section so that
no problem occurs when the remaining code runs. It is executed only once during
the uploading of the program and after resetting or powering up the Arduino
board.
Zero setup () resides at the top of each sketch. When the program runs after
completion, it heads towards the setup section to initialize the setup and include
all the necessary libraries all at once.
Loop
The loop contains statements that are executed repeatedly. Unlike, the setup
section there is no restriction on running this code once, it can run multiple times
according to the value of variables.
Time
The basic unit of measuring time in Arduino programming is a millisecond.
1 sec = 1000 milliseconds
Timing adjustments can be made in milliseconds. A better explanation for this can
be that a 2-second delay corresponds to 2000 milliseconds.

Example
A simple example of blinking the LED using Arduino is considered.
The steps are:
1. Go to the menu bar. Click on the File button in the bar.
2. Click on the Examples in the menu bar.
3. Click on the Basics option.
4. You will see Blink, click it.

This is the window that opens:


Blinking the LED Image Credit-Arduino IDE:https://www.arduino.cc/en/software

Note: The pinMode will be the main function in the void setup() and digitalWrite( )
and delay ( ) will be the main function in the void setup()
PinMode ( )
The pinMode() function assigns a specific PIN as either INPUT or OUTPUT.
The Syntax is:
pinMode (pin, mode)
Pin: It is used to specify the PIN which depends on the project requirements.
Mode: Depending on whether the pin is taking INPUT or OUTPUT, it specifies the
pin's function.
Let's consider a situation to understand the pinMode. We want to take input from
the PIN 13 and then,
Code:
pinMode (13, INPUT);
PinMode in OUTPUT mode
Setting pinMode to OUTPUT is important for some pins. This mode allows the
specified PIN to supply sufficient current to another circuit to activate the sensor
or light the LED. When set to OUTPUT, this pin goes into a very low impedance
state, making the current useful. It is important to note that excessive current or
short circuits between pins can damage the Atmel chip. This explains the need for
setting the mode to OUTPUT.
PinMode in INPUT mode
When digitalWrite() is used, selecting the INPUT mode for any pin turns off the low
state and sets the high state as the ultimate state. The INPUT mode can be
employed alongside an external pull-down resistor. For this purpose, pinMode
should be set to INPUT_PULLUP. This configuration reverses the behavior of the
INPUT mode. In INPUT_PULLUP mode, a sufficient current is provided to light an
LED connected to the pin dimly. If the LED emits a dim light, it signifies that this
condition is operational.
Given these considerations, it's advisable to set the pin to OUTPUT mode to ensure
proper functionality.
digitalWrite( )
The digitalWrite( ) function is used to decide the value of the pin. It can be set as
either of the two values, HIGH or LOW.
HIGH: For a board that is supplied with a maximum of 1V, it results in a 5V value
whereas on a board with other values like 6V, it updates the value to 6V.
LOW: It sets the pin to the ground by setting a reference of 0V.
If no pin is set with pinMode as OUTPUT, the LED may light dim.
The syntax is:
digitalWrite( pin, value HIGH/LOW)
Pin: We can specify the PIN or the declared variable.
Let's understand with an example.
Example:
digitalWrite (6, HIGH);
digitalWrite (6, LOW);
The HIGH will be used for setting the pin at number 6 high and it will ultimately
turn on the LED if connected to this pin while, the LOW will be used for setting the
pin at number 6 low and it will ultimately turn off the LED if connected to this pin.
delay ( )
The delay() function serves as a tool to halt program execution for a specified
duration, measured in milliseconds. We have seen how delay(5000) signifies a
stop of 5 seconds.
This can be understood by the fact that 1 second equals 1000 milliseconds.
Code:
digitalWrite (12, HIGH);
delay (5000);
digitalWrite (12, LOW);
delay (2000);
The program here is that the LED is connected to the pin having PIN 12 and it will
remain lit for 5 seconds before turning and then will go off. The LED will then be
turned off for 2 seconds as specified by delay(). This cycle will continue in a loop
depending on the defined variables within the void loop() function.
Solved Example
Let us try to code the control of the LED on PIN 12, by designing it to
remain ON for 3 seconds and remain OFF for 2.5 seconds. Here is the
code
Pseudocode:
Firstly, we will need to set a particular pin as the output pin therefore, we will set
the pin number 12 as the input in setup() block.
Then we need to set the pin number 12 high using the digitalWrite() function.
Then we use the delay() function to keep the LED on for 3 seconds.
Then we need to set the pin number 12 low using the digitalWrite() function.
Then we use the delay() function to keep the LED off for 2.5 seconds.
Code:
void setup () {
pinMode ( 12, OUTPUT); // to set the OUTPUT mode of pin number 13.
}
void loop () {
digitalWrite (12, HIGH);
delay (3000); // 3 seconds = 3 x 1000 milliseconds
digitalWrite (12, LOW);
delay (2500); // 2.5 seconds = 2.5 x 1000
milliseconds
}

Advantages and Disadvantages of Arduino


Advantages of Arduino
We need to know the reason for selecting Arduino over other devices so let us
study some advantages of Arduino.
 Arduino is the best choice for starting your programming journey in electronics.
Its easy-to-use interface allows users to build simple projects on their own.
 There is no need for experience or hands-on experience in electronics before
starting work on Arduino. Anyone with a genuine interest in Arduino can begin
learning through simple tutorials and some guidance. These tutorials are
available free of cost for creating some beginner-level and advanced projects.
 Arduinos offer a wide range of options. You can use Arduino alone to create
some projects or you can add some extra features by integrating it with other
devices like Raspberry Pie.
 Arduino is an open-source tool that can be accessed from different locations
and platforms. Due to the inexpensive nature of Arduinos, they can be used on
different microcontrollers like Atmel's ATMEGA 16U2 microcontrollers.
 Depending on the need of your project, you can avail of any Arduino that
satisfies the needs. These Arduino are available in different designs that offer
different size ranges, power, and specifications.
Disadvantages of Arduino
Let us see some limitations associated with Arduino:
 Despite being able to communicate with other boards like Raspberry pies and
other Arduinos, the communication of Arduino is very restricted since it is
installed to use certain basic communication protocols.
 Arduinos have been designed for beginner-level projects as a result they have
Limited Memory and Processing Power which limits the projects that can be
made using Arduino.
 Due to the lack of excess security in Arduino boards, they can be easily hacked
which can result in loss and data leakage.
 When it comes to accuracy, the Arduino board is not the best choice since it
lacks the precision needed for analog to digital conversion.
 Arduino responds and coordinates tasks based on the responsiveness of other
components due to which it can not be programmed for real-time applications.

Application of Arduino
Arduino finds its applications in various fields due to their ability to perform
different things. Let us see some of its applications:
 Arduinos are used in 3D printing where they perform the task of selecting how
the printing will be performed.
 Arduinos are used for creating basic designs by makers, designers, hackers,
and creators across the globe to create some great projects. Some of the
projects are Laser Turret Midi Controller, Retro Gaming With an OLED Display,
and Traffic Light Controller.
 Arduinos are used in the field of robotics for programming robots and adding
basic features like sensing and responding to environmental conditions.
 Arduino is used in IoT(Internet of Things) since it can collect information using
sensors. The collected data is then processed and transmitted for developing
various smart devices.

You might also like