Unit IV Low Cost Automation
Unit IV Low Cost Automation
A transducer can be defined as device capable of converting energy from one form into
anothe.
A sensor is a physical device or biological organ that detects, or senses, a signal or physical
condition and chemical compounds and provides electrical output. Sensors are devices that provide
an interface between electronic equipment and the physical world. Often the active element of a
sensor is referred to as a transducer.
SENSOR TERMINOLOGY
(a) Sensitivity: Sensitivity of a sensor is defined as the change in output of the sensor per unit change
in the parameter being measured. The factor may be constant over the range of the sensor
(linear), or it may vary (nonlinear).
(b) Range: Every sensor is designed to work over a specified range. The design ranges are usually
fixed, and, if exceeded, result in perma- nent damage to or destruction of a sensor. Range is the
difference between maximum and minimum values of the applied parameter that can be
measured.
(d) Resolution: Resolution is defined as the smallest change that can be detected by a sensor. In
other words, it is the response of the mea- suring instrument for small variations in the input
parameter.
(e) Accuracy: A very important characteristic of a sensor is accuracy, which really means
inaccuracy. Inaccuracy is measured as a ratio of the highest deviation of a value represented by
the sensor to the ideal value. It may be represented in terms of measured value.
(f) Hysteresis: Hysteresis is the difference in response for increasing and decreasing values of the
applied parameter.
(g) Response time: The time taken by a sensor to approach its true out- put when subjected to a step
input is sometimes referred to as its response time.
(h) Offset: Offset is the sensor output that exists when it should be zero.
SELECTION OF A TRANSDUCER
The following factors should be kept in mind while selecting a trans- ducer. The transducer
should:
v Recognize and sense the desired input signal and should be sensitive to other signals.
v Have good accuracy.
v Have good precision.
v Have amplitude linearity.
v Have environmental compatibility, i.e., corrosive fluids, pressure, shocks, size, etc.
CLASSIFICATION OF SENSORS
1. Thermal energy. For measuring temperature, flux, conductivity, and spe- cific heat.
2. Electromagnetic sensors. For measuring voltage, current, charge, mag- netic field, flux, and
permeability.
3. Mechanical sensors. For measuring quantities such as position, shape, velocity, force, torque,
pressure, strain, and mass.
v Gas and liquid flow sensors: flow sensor, flow meter, gas meter, water meter.
v Strain gauge
4. Chemical sensors
6. Acoustic sensors
CLASSIFICATION OF TRANSDUCERS
Self-generating transducers are those which produce their own electrical signal (either
current or voltage). For example, thermocouple, thermopile, moving coil generator, piezoelectric
pick up, photovoltaic cell, etc.
Non–self-generating type transducers are those which are not capable of generating their own
signals. These will not produce an electrical sig- nal of their own but show some variations of
resistance, capacitance, and inductance. For example, thermistor, linear variable differential transducer,
capacitive pick up, strain gauge, resistance temperature detector, etc.
Input transducers are those that have electronic output and another form of energy as input,
i.e., input transducers convert a quantity to an electrical signal (voltage) or to resis- tance (which
can be converted to voltage). Examples: Light dependent resistor (LDR) converts brightness (of
light) to resistance, thermistor converts temperature to resistance, microphone converts sound to
voltage, variable resistor converts position (angle) to resistance, etc.
Output transducers are those that have electronic input and another form of energy for
output. Examples: lamp converts electricity to light, LED converts electricity to light, loudspeaker
converts electricity to sound, motor converts electricity to motion, heater converts electricity to
heat, etc.
Analog transducer converts input signal into output signal, which is a continuous function of
time such as thermistor, strain gauge, thermocouple, LVDT, etc.
A digital transducer converts the input signal into the output signal of the form of pulse that
gives discrete output.
TEMPERATURE SENSORS
The basic construction of an RTD is quite simple. It consists of a length of fine-coiled wire
wrapped around a ceramic or glass core. The element is usually quite fragile, so it is often placed
inside a sheathed probe to protect it.
Common resistance materials for RTDs are platinum, nickel, and cop- per. Platinum is the most
commonly used metal for RTDs due to its stability and nearly linear temperature. It can measure
temperatures up to 800°C. The resistance of the RTD changes as a function of absolute temperature, so
it is categorized as one of the absolute temperature devices. (In contrast, the ther- mocouple cannot
measure absolute temperature; it can only measure relative temperature.)
Thermocouple
When two dissimilar metal conductors are connected together to form a closed circuit and
the two junctions are kept in different temperatures, thermal electromotive force (EMF) is
generated in the circuit (Seebeck’s effect). Thermocouples make use of this so-called Peltier-
Seebeck effect.
Thus, when one end (cold junction) is kept constant at a certain temperature, normally at 0°C,
and the other end (measuring junction) is exposed to an unknown temperature, the temperature at latter
end can be determined by measurement of EMF so generated. This combination of two dissimilar
metal conductors is called “thermocouple”.
Thermistor
A thermistor is an electronic component that exhibits a large change in resistance with a
change in body temperature. Thermistors are highly sensitive to temperature variation; hence, they
are also called temperature sensitive resistors. Thermistors are manufactured from metal oxide
semiconductor material, which is encapsulated in a glass or epoxy bead.
Thermistors are divided into negative temperature coefficient (NTC) and positive
temperature coefficient (PTC) types. The temperature coefficient of a material can be defined as
change in resistance of the material for a unit degree change in temperature
LIGHT SENSORS
When light strikes special types of materials, a voltage may be generated, a change in
electrical resistance may occur, or electrons may be ejected from the material surface. Some of
the commonly used light sensors are discussed below:
Photoresistors
Photoresistors, as their name suggests, are resistors whose resistance is a function of the
amount of light falling on them. Their resistance is very high when no light is present and
significantly lower when they are illuminated. These are also often called light-dependent resistors
(LDRs) (refer to Figure 11.5). Photoresistors can be used as light sensors, which can enable robot
behaviors such as hiding in the dark, moving toward a beacon, etc.
Photodiode
POSITION SENSORS
A position, or linear displacement sensor, is a device whose output sig- nal represents the
distance an object has traveled from a reference point. Types of position/displacement sensors are:
• Inductive sensors
• Magnetostrictive sensors
Inductive Sensors
Inductive sensors are contact-free, inherently robust, and have infinite resolution with high
repeatability. They are often used where long-term reliability is important, particularly in harsh and
hostile environments. There are two basic types of inductive sensors:
With excitation of the primary coil, induced voltages will appear in the secondary coils.
Because of the symmetry of magnetic coupling to the primary, these secondary induced voltages are
equal when the core is in the central (“null” or “electric zero”) position. When the secondary coils
are connected in series opposition, as shown in the figure, the secondary voltages will cancel and
(ideally) there will be no net output voltage.
If, however, the core is displaced from null position, in either direction, one secondary voltage
will increase, while the other decreases. Because the two voltages no longer cancel, a net output
voltage will now result. The dif- ference in induced voltages produces an output that is linearly
proportional in magnitude to the displacement of the core.
(b) Rotary Variable Differential Transducer (RVDT): The rotational variable differential
transducer (RVDT) is used to measure rotation al angles and operates under the same principles as the
LVDT sensor. Whereas the LVDT uses a cylindrical iron core, the RVDT uses a rotary
ferromagnetic core. It is similar to the LVDT except that its core is cam shaped and may be rotated
between the windings by means of a shaft.
Along with a sensing surface formed by two metal electrodes, the capacitive proximity
sensor involves a high-frequency oscillator. When an object comes near the sensing surface, it
changes the capacitance of the oscillator by entering into the electrostatic field of the
electrodes. Due to this, the oscillator circuit begins to oscillate and variates the output state of
the sensor when it reaches a certain amplitude. The oscillator’s amplitude decreases as the
object moves away from the sensor, switching the sensor back to its initial state.
Magnetostrictive Sensor
The magnetostrictive effect is the change of the resistivity of a material due to a magnetic
field. Magnetostriction is a property of ferromagnetic materials such as iron, nickel, and cobalt.
When placed in a magnetic field, these materials change size and/or shape. Magnetostrictive
materials convert magnetic energy to mechanical energy and vice versa.
Magnetic Sensors or Hall-Effect Sensors
These produce output voltages proportional to the strength of a nearby magnetic field
generated by a moving magnet.
PIEZOELECTRIC SENSORS
These sensors are used to measure strain or force by converting them to an electrical signal -
when a pressure is applied to a piezoelectric material, it causes a mechanical deformation and a
displacement of charges. Those charges are highly proportional to the applied pressure.
PRESSURE SENSORS
STRAIN GAUGES
The operation of the resistance strain gauge is based on the principle, that the electrical
resistance of a conductor changes when it is subjected to a mechanical deformation, since the
resistivity changes with a change in length and area. Figure shows a resistance wire in its original
state, and after that subjected to a strain. The stretched wire has higher resis- tance, as it is longer
and thinner.
Types of Strain Gauges
Some of the com- monly used strain gauges are discussed below:
1. Resistance Strain Gauges
The resistance of an electrically conductive material changes with dimen- sional changes, which take
place when the conductor is deformed elastically. When such a material is stretched, the conductors
become longer and narrower, which causes an increase in resistance.
Capacitance devices, which depend on geometric features, can be used to measure strain. The
capacitance of a simple parallel plate capacitor is
Signal Processing
Signal processing is a key area of electrical engineering that deals with the analysis, modification, and
synthesis of signals such as sound, images, and biological measurements. It plays a critical role in systems
like communication, control systems, and data analysis.
o Analog Signal: An analog signal is a type of signal where the information is represented by
continuous, smooth variations in voltage, current, or other physical quantities over time. The
signal exists and can be measured at every instant in time.
Example: A sine wave representing sound waves.
o Digital Signal: A type of signal where information is represented using discrete, binary values—
typically 0s and 1s. Unlike analog signals, which vary continuously, digital signals have specific,
fixed levels for different states, making them less susceptible to noise and easier to process with
digital systems.
o Filtering
o Amplifying
o Sampling
o ADC (Analog-to-Digital Conversion)
o DAC (Digital-to-Analog Conversion)
Filtering
Filtering is the process of modifying a signal by selectively passing or rejecting certain frequency
components.
Types of Filters:
Ø Low-Pass Filter (LPF): Passes low-frequency signals and attenuates high-frequency signals.
Example: Used in audio systems to remove high-frequency noise from a signal.
Ø High-Pass Filter (HPF): Passes high-frequency signals and attenuates low-frequency signals.
Example: Used in audio processing to remove low-frequency hum from recordings.
Ø Band-Pass Filter (BPF): Passes frequencies within a specific range and attenuates those outside.
Example: Used in radio receivers to select a desired signal frequency while rejecting others.
Ø Band-Stop Filter (Notch Filter): Rejects frequencies within a specific range.
Example: Used to remove unwanted frequencies like power line interference (60 Hz) in biomedical
signals.
2. Amplifying
Amplifying is the process of increasing the amplitude of a signal without significantly altering its
waveform. It’s essential when signals are weak and need to be strengthened for further processing or
transmission. Amplification is crucial when using sensors because most sensors produce very small
electrical signals, often in the millivolt or microvolt range, which are too weak to be directly processed or
interpreted by systems like microcontrollers, analog-to-digital converters (ADC), or display units.
Many sensors, such as thermocouples, strain gauges, and photodiodes, produce very low output signals.
These small signals may not be detectable by downstream electronics due to noise or insufficient sensitivity.
Example: A thermocouple might generate a voltage of only a few millivolts, which is too small for many
ADCs or microcontrollers to measure accurately.
By amplifying the signal, you increase the signal-to-noise ratio (SNR), making the signal easier to
distinguish from background noise. Noise becomes more significant in low-level signals, and amplification
helps improve the signal quality before further processing.
Analog-to-digital converters (ADCs) often require input signals within a specific voltage range (e.g., 0–
5V). If the sensor output is much lower than this range, amplification is needed to scale the sensor signal to
match the ADC input range for accurate digitization.
4. Enhanced Sensitivity
In many applications, sensor outputs need to be sensitive to minute changes in the environment (such as
temperature, pressure, or light). Amplification helps detect these small variations by making even tiny
changes in the sensor’s output more noticeable and easier to measure.
When a sensor signal has to travel through long cables or other components before reaching the
processing unit, it may experience attenuation (signal loss). Amplifying the signal before transmission
ensures that enough of the original signal reaches the destination without being overwhelmed by noise or
attenuation.
In some cases, amplified sensor signals are needed to drive actuators or display devices, such as motors,
LEDs, or gauges. The unamplified sensor output would be too small to cause meaningful action in these
devices.
Types of Amplifiers:
3. Sampling
Sampling is the process of converting a continuous-time (analog) signal into a discrete-time signal by
taking periodic measurements (samples) of the signal’s amplitude at regular intervals.
Sampling Rate: The number of samples taken per second, measured in Hertz (Hz).
Example: In audio processing, a common sampling rate is 44.1 kHz (44,100 samples per second).
Nyquist-Shannon Sampling Theorem: To accurately reconstruct the original signal, the sampling rate
must be at least twice the highest frequency present in the analog signal. This is known as the Nyquist
rate. Example: If the highest frequency in a signal is 10 kHz, the sampling rate must be at least 20 kHz
to avoid aliasing (distortion caused by undersampling).
Aliasing: Occurs when the sampling rate is too low, causing high-frequency components to appear as
lower frequencies, distorting the signal.
The Sample and Hold circuit is an electronic circuit which creates the samples of voltage given
to it as input, and after that, it holds these samples for the definite time. The time during which
sample and hold circuit generates the sample of the input signal is called sampling time.
Similarly, the time duration of the circuit during which it holds the sampled value is called
holding time.
The diagram shows the circuit of the sample and hold circuit with the help of an Operational
Amplifier. It is evident from the circuit diagram that two OP-AMPS are connected via a switch.
When the switch is closed sampling process will come into the picture and when the switch is
opened holding effect will be there. The capacitor connected to the second operational amplifier is
nothing but a holding capacitor.
Application of Sampling:
o Digital Audio: Converting analog audio signals into digital form by sampling at rates like
44.1 kHz or 48 kHz.
o Image Processing: Sampling the intensity of light at regular intervals to convert continuous
images into discrete pixel values.
4. Analog-to-Digital Conversion (ADC)
Steps in ADC:
o Sampling: The analog signal is measured at regular time intervals (sampling rate).
o Quantization: Each sample is approximated to the nearest value within a finite set of discrete
levels. The more levels, the higher the precision.
o Encoding: Each quantized sample is then converted into a binary number.
ADC Parameters:
o Resolution: The number of bits used to represent each sample. Higher resolution means
more precise quantization. For example, an 8-bit ADC can represent 256 levels, while a 16-
bit ADC can represent 65,536 levels.
o Sampling Rate: The frequency at which the signal is sampled. A higher sampling rate
provides more detail about the signal.
2-bit Analogue to Digital Converter Circuit
As VIN increases above 1 volt, but is less than 2 volts, (1V<VIN<2V) comparator U1 which
has a reference voltage input set at 1 volt, will detect this voltage difference producing a HIGH
output. The priority encoder which is used as the 4-to-2 bit encoding detects this change of input
voltage at D1 and produces a binary output of “1” (01).
Applications of ADC:
o Audio Recording: Converting analog audio signals to digital for storage on devices like CDs
or digital media players.
o Biomedical Devices: Converting physiological signals like ECG or EEG into digital form
for analysis and monitoring.
o Sensor Data Acquisition: Converting sensor outputs (e.g., temperature or pressure) to digital
form for processing by microcontrollers or computers.
Digital-to-Analog Conversion (DAC) is the reverse process of ADC, where a discrete digital
signal is converted back into a continuous analog signal.
Steps in DAC:
o Binary to Analog: The digital signal, which is a sequence of binary numbers, is converted
into a corresponding sequence of voltage or current levels.
o Smoothing: To reconstruct a smooth analog signal, the output of a DAC is typically passed
through a low-pass filter to remove high-frequency components introduced by the digital
representation.
Applications of DAC:
o Audio Playback: Converting digital audio data back into analog signals to drive speakers or
headphones (e.g., in smartphones, MP3 players).
o Video Systems: Converting digital video data to analog signals for use in older analog
display devices.
o Control Systems: Converting digital control signals to analog form for actuating devices like
motors and sensors.
Key Concepts in ADC & DAC:
o Quantization Error: The difference between the actual analog value and its quantized digital
representation. More bits in the ADC/DAC reduce this error.
o Signal-to-Noise Ratio (SNR): A measure of the signal quality relative to background noise.
Higher-resolution ADCs/DACs provide better SNR.
o Sampling Rate & Bit Depth: High sampling rates capture more details of the signal, and
greater bit depth provides more precise amplitude representation.
Servo Motors
A servo motor is defined as an electric motor that allows for precise control of angular or
linear position, speed, and torque. It consists of a suitable motor coupled to a sensor for position
feedback and a controller that regulates the motor’s movement according to a desired setpoint.
A servo motor is an electric motor that adjusts its position, speed, or torque in response to
controller inputs.
1. Motor: This can be either a DC motor or an AC motor depending on the power source and the
application requirements. The motor provides the mechanical power to rotate or move the output
shaft.
2. Sensor: This can be either a potentiometer, an encoder, a resolver, or another device that
measures the position, speed, or torque of the output shaft and sends feedback signals to the
controller.
3. Controller: This can be either an analog or a digital circuit that compares the feedback signals
from the sensor with the desired setpoint signals from an external source (such as a computer or a
joystick) and generates control signals to adjust the motor’s voltage or current accordingly.
The controller employs a closed-loop feedback system, adjusting the motor’s movement to
closely align with the desired setpoint, maintaining strict accuracy.
The controller can also implement various control algorithms, such as proportional-integral-
derivative (PID) control, fuzzy logic control, adaptive control, etc., to optimize the performance of
the servo motor.
The basic working principle of a servo motor involves the controller receiving two types of
input signals:
o A setpoint signal: This is an analog or digital signal that represents the desired position,
speed, or torque of the output shaft.
o A feedback signal: This is an analog or digital signal that represents the actual position,
speed, or torque of the output shaft measured by the sensor.
The controller compares these two signals and calculates an error signal that represents the
difference between them.
The error signal is then processed by a control algorithm (such as PID) that generates a control
signal that determines how much voltage or current should be applied to the motor.
The motor then rotates or moves according to the control signal and changes its position, speed,
or torque, and sends a new feedback signal to the controller.
The process repeats until the error signal becomes zero or negligible, indicating that the output
shaft has reached the desired setpoint.
Servo motors can be classified into different types based on their power source, construction,
feedback mechanism, and application.
i) AC Servo Motors
o AC servo motors are electric motors that operate on alternating current (AC). They have a
stator that generates a rotating magnetic field and a rotor that follows the field.
o AC servo motors, powered by alternating current, feature a stator that creates a rotating
magnetic field, with a rotor that synchronizes with this field for efficient operation.
o AC servo motors are suitable for high-power applications that require high speed, torque,
and reliability. They are commonly used in industrial machines, robotics, CNC machines,
etc.
ii) DC Servo Motors
o DC servo motors are electric motors that operate on direct current (DC). They have a
permanent magnet stator that generates a fixed magnetic field and a wound rotor that rotates
when a current is applied.
o DC servo motors can be further divided into two types: brushed and brushless.
Arduino
Arduino-Hardware
o 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.
o 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.
o 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.
o 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.
o 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.
o 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
o 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.
o 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.
Arduino Coding
Brackets
There are two types of brackets utilized in Arduino coding, as given below:
o 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 ‘( )’.
o 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 ‘{ }’.
v Open curly bracket- ‘ { ‘
v Closed curly bracket – ‘ } ‘
o Line Comment
Ø There are two types of line comments, let us study them individually:
v 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.
// This is a comment
v 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, 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:
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.
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
Timing adjustments can be made in milliseconds. A better explanation for this can be that a
2-second delay corresponds to 2000 milliseconds.
PinMode ( )
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.
o 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.
o LOW: It sets the pin to the ground by setting a reference of 0V
o If no pin is set with pinMode as OUTPUT, the LED may light dim.
o The syntax is: digitalWrite( pin, value HIGH/LOW) - digitalWrite (6, HIGH);
o 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.
digitalWrite (12, HIGH);
delay (5000);
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:
i) 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.
ii) Then we need to set the pin number 12 high using the digitalWrite() function.
iii) Then we use the delay() function to keep the LED on for 3 seconds.
iv) Then we need to set the pin number 12 low using the digitalWrite() function.
v) 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 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.
Disadvantages of 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.