2. Learning Outcomes-
➔ What is LED?
➔ Interfacing of LED with Arduino UNO Board
➔ Coding or Algorithm
➔ What is LCD?
➔ Interfacing of LCD with Arduino UNO Board
➔ Serial communication using Arduino IDE
➔ Concept of ADC in ATMEGA 328
➔ Interfacing of temperature sensor with Arduino board, LVDT, Strain
gauge
3. What is LED?
● A light-emitting diode (LED) is a semiconductor device that emits light when an
electric current flows through it.
● Features: Long lifespan, Low cost & size, high luminance, low power
consumption, Energy Efficiency.
4. Interfacing of ATMEGA 328 based Arduino board with LED
● LED cathode is connected to GND.
● GPIO pin no. 9 of board is connected
With LED anode through resistor
(It’s value is inversely proportional to
current & brightness of LED).
5. Program or Code:
void setup()
{
pinMode(9, OUTPUT); // initialize digital pin 9 as an output.
}
void loop() // the loop function runs over and over again forever
{
digitalWrite(9, HIGH ); // turn the LED ON by making the voltage
HIGH
delay(1000); // Wait for a second
digitalWrite(9, LOW); // turn the LED ON by making the voltage
LOW
delay(1000); // Wait for a second
}
8. What is LCD?
● LCD is a flat display technology, stands for "Liquid Crystal Display”.
● Used in computer monitors, instrument panels, cell phones, digital cameras, TVs,
laptops, tablets, and calculators.
● It is a thin display device that offers support for large resolutions and better picture
quality.
● 16×2 LCD display is shown below:
9. Interfacing of LCD with ATMEGA 328 based Arduino board:
Figure: Circuit diagram of connecting 16*2 LCD with Arduino board
11. Example to blink the output on LCD:
#include <LiquidCrystal.h> // initialize the library
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
lcd.clear();
delay(1000);
lcd.setCursor(0, 0);
lcd.print(“Hello….! );
lcd.setCursor(0, 1);
lcd.print(“Hi….”);
delay(1000);
}
12. Serial communication using Arduino IDE:
● Arduino UNO pins 0 &1 are of UART used for serial communication.
● UART requires two pins for communication: Tx & Rx.
● Connection of Atmega328 on Arduino Uno board to PC:
15. ADCSRA – ADC Control and Status Register A:-
Bit 7 6 5 4 3 2 1 0
0x7A ADEN ADSC ADATE ADIF ADIE ADPS2 ADPS1 ADPS0
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
16. ● Bit 7 – ADEN: ADC Enable: Writing this bit to one enables the ADC. By writing it to
zero, the ADC is turned off. Turning the ADC off while a conversion is in progress, will
terminate this conversion.
● Bit 6 – ADSC: ADC Start Conversion: In Single Conversion mode, write this bit to one
to start each conversion. In Free Running mode, write this bit to one that will take 25
ADC clock cycles instead of the normal 13 This first conversion performs initialization of
the ADC. ADSC will read as one as long as a conversion is in progress. When the
conversion is complete, it returns to zero.
● Bit 5 – ADATE: ADC Auto Trigger Enable: When this bit is written to one, Auto
Triggering of the ADC is enabled. The ADC will start a conversion on a positive edge of
the selected trigger signal. The trigger source is selected by setting the ADC Trigger Select
bits, ADTS in ADCSRB.
17. ● Bit 4 – ADIF: ADC Interrupt Flag:
This bit is set when an ADC conversion completes and the Data Registers are updated.
The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I-bit in
SREG are set. ADIF is cleared by hardware when executing the corresponding interrupt
handling vector.
● Bit 3 – ADIE: ADC Interrupt Enable:
When this bit is written to one and the I-bit in SREG is set, the ADC Conversion
Complete Interrupt is activated.
18.
19. ● Bits 2:0 – ADPS[2:0]: ADC Prescaler Select Bits: These bits determine the division
factor between the system clock frequency and the input clock to the ADC.
● ADPS2 ADPS1 ADPS0 Division Factor
0 0 0 2
0 0 1 2
0 1 0 4
0 1 1 8
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
20. ADCSRB – ADC Control and Status Register B:
Bit 7 6 5 4 3 2 1 0
– ACME – – – ADTS2 ADTS1 ADTS0
Read/Write R R/W R R R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0
0
21. ● Bit 7,5,4 ,3:Reserved bits:Input
This bits are used for future purpose.
● Bit 6-ACME:
ACME=1 & ADC is switched off, ADC multiplexer selects input connected at
ADC channels as negative input to the analog comparator.
ACME=0 AIN1 acts as negative terminal of analog comparator.
22. Bit 2:0 – ADTS[2:0]: ADC Auto Trigger Source selection
If ADATE in ADCSRA is written to one, the value of these bits selects which source will trigger an ADC
conversion.
ADTS2 ADTS1 ADTS0 Trigger Source
0 0 0 Free Running mode
0 0 1 Analog Comparator
0 1 0 External Interrupt Request 0
0 1 1 Timer/Counter0 Compare Match A
1 0 0 Timer/Counter0 Overflow
1 0 1 Timer/Counter1 Compare Match B
1 1 0 Timer/Counter1 Overflow
1 1 1 Timer/Counter1 Capture Event
24. Bit 7:6 – REFS[1:0]: Reference Selection Bits:
25. Bit 5 – ADLAR: ADC Left Adjust Result
The ADLAR bit affects the presentation of the ADC conversion result in the ADC Data
Register. Write one to ADLAR to left adjust the result. Otherwise, the result is right
adjusted.
• Bits 3:0 – MUX[3:0]: Analog Channel Selection Bits
The value of these bits selects which analog inputs are connected to the ADC.
27. ADCL and ADCH – The ADC Data Register: ADLAR = 1 :When
an ADC conversion is complete, the result is found in these two registers. A total of 10 bits
of conversion result is stored in these two registers.
Bit 15 14 13 12 11 10 9 8
0x79 ADC9 ADC8 ADC7 ADC6 ADC5 ADC4 ADC3 ADC2
Read/Write R R R R R R R R
Bit 7 6 5 4 3 2 1 0
0x78 ADC1 ADC0 – – – – – –
Read/Write R R R R R R R R
28. Bit 15 14 13 12 11 10 9 8
0x79 – – – – – – ADC9 ADC8
Read/Write R R R R R R R R
Bit 7 6 5 4 3 2 1 0
0x78 ADC7 ADC6 ADC5 ADC4 ADC3 ADC2 ADC1 ADC0
Read/Write R R R R R R R R
ADLAR = 0
29. DIDR0 – Digital Input Disable Register 0:
Bit 7 6 5 4 3 2 1 0
0x7E – – ADC5D ADC4D ADC3D ADC2D ADC1D ADC0D
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0
0
30. Bit 5:0 – ADC5D…ADC0D: ADC5…0 Digital Input Disable
When this bit is written logic one, the digital input buffer on the corresponding
ADC pin is disabled. The corresponding PIN Register bit will always read as zero
when this bit is set. When an analog signal is applied to the ADC5…0 pin and the
digital input from this pin is not needed, this bit should be written logic one to
reduce power consumption in the digital input buffer.
31. What is temperature sensor?
● The Temperature Sensor LM35 series are precision
integrated-circuit temperature devices with an output
voltage linearly proportional to the Centigrade
temperature.
● The LM35 device calibrated in Kelvin.
● The LM35 device does not require any external
calibration or trimming to provide typical accuracies
of ±¼°C at room temperature and ±¾°C over a full
−55°C to 150°C temperature range.
32. Features:
● Calibrated Directly in Celsius (Centigrade)
● Linear + 10-mV/°C Scale Factor.
● 0.5°C Ensured Accuracy (at 25°C)
● Rated for Full −55°C to 150°C Range.
● Suitable for Remote Applications.
● Low-Cost Due to Wafer-Level Trimming.
● Operates From 4 V to 30 V.
36. What is LVDT?
● The term LVDT stands for the Linear
Variable Differential Transformer.
● It is the most widely used inductive
transducer that converts the linear motion into
the electrical signal.
● The output across secondary of this
transformer is the differential.
37.
38. ● The transformer consists of a primary winding P and two secondary windings S1 and S2
wound on a cylindrical former (which is hollow in nature and contains the core).
● Both the secondary windings have an equal number of turns and we place them on either
side of primary winding
● The primary winding is connected to an AC source which produces a flux in the air gap
and voltages are induced in secondary windings.
● A movable soft iron core is placed inside the former and displacement to be measured is
connected to the iron core.
● The iron core is generally of high permeability which helps in reducing harmonics and
high sensitivity of LVDT.
● The LVDT is placed inside a stainless steel housing because it will provide electrostatic
and electromagnetic shielding.
● The both the secondary windings are connected in such a way that resulted output is the
difference between the voltages of two windings.
39. Principle of Operation and Working:
● CASE I When the core is at null position (for no displacement)
When the core is at null position then the flux linking with both the secondary windings is
equal so the induced emf is equal in both the windings. So for no displacement the value of
output eout is zero as e1 and e2 both are equal. So it shows that no displacement took place.
● CASE II When the core is moved to upward of null position (For displacement to the
upward of reference point)
In the this case the flux linking with secondary winding S1 is more as compared to flux
linking with S2. Due to this e1 will be more as that of e2. Due to this output voltage eout is
positive.
● CASE III When the core is moved to downward of Null position (for displacement to the
downward of the reference point). In this case magnitude of e2 will be more as that of e1.
Due to this output eout will be negative and shows the output to downward of the reference
point.
40. Advantages of LVDT:
● High Range – The LVDTs have a very high range for measurement of
displacement.they can used for measurement of displacements ranging from 1.25
mm to 250 mm
● No Frictional Losses – As the core moves inside a hollow former so there is no
loss of displacement input as frictional loss so it makes LVDT as very accurate
device.
● High Input and High Sensitivity – The output of LVDT is so high that it doesn’t
need any amplification. The transducer possesses a high sensitivity which is
typically about 40V/mm.
● Low Hysteresis – LVDTs show a low hysteresis and hence repeatability is
excellent under all conditions
● Low Power Consumption – The power is about 1W which is very as compared
to other transducers.
● Direct Conversion to Electrical Signals – They convert the linear displacement
to electrical voltage which are easy to process.
41. Disadvantages of LVDT:
● LVDT is sensitive to stray magnetic fields so it always requires a setup to
protect them from stray magnetic fields.
● LVDT gets affected by vibrations and temperature.
Applications of LVDT
1. We use LVDT in the applications where displacements to be measured
are ranging from a fraction of mm to few cms.
2. The LVDT can also act as a secondary transducer. E.g. the Bourbon tube
which acts as a primary transducer and it converts pressure into linear
displacement and then LVDT coverts this displacement into an electrical
signal which after calibration gives the readings of the pressure of fluid.
42. Circuit diagram of LVDT with Arduino board: (For low
output LVDT)
LVDT
Precision Amplifier
45. Code or Algorithm:
Float D;
void setup()
{
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop()
{
D = (2*4.882* analogRead(A0))/8000;
Serial.print("Displacement is = ");
Serial.println((float)D);
delay(1000);
}
46. What is strain gauge?
● Strain Gauge is a transducer which generates an electrical signal whose
magnitude is proportional to the force applied.
● Strain gauge is used to measure strain.
48. Strain Gauge Working Principle:
● The foil type strain gauges (Figure1) are very common in which a resistive foil
is mounted on a backing material. These are available in a variety of shapes
and sizes for different applications. The resistance of the foil changes as the
material to which the gauge is attached undergoes tension or compression due
to change in its length and diameter.
● This change in resistance is proportional to the applied strain. As this change in
resistance is very small in magnitude so its effect can be only sensed by a
Wheatstone bridge. This is the basic strain gauge working principle.
49. ● A circuit diagram is shown in Figure 2. In this circuit diagram, a strain gauge is
connected into a Wheatstone bridge. This circuit is so designed that when no force
is applied to the strain gauge, R1 is equal to R2 and the resistance of the strain
gauge is equal to R3. In this condition the Wheatstone bridge is balanced and the
voltmeter shows no deflection.
● But when strain is applied to the strain gauge, the resistance of the strain gauge
sensor changes, the Wheatstone bridge becomes unbalanced, a current flows
through the voltmeter. Since the net change in the resistance is proportional to the
applied strain, therefore, resultant current flow through the voltmeter is
proportional to the applied strain. So, the voltmeter can be calibrated in terms of
strain or force.
50. Advantages:
● In the strain gauge you will find no moving parts.
● Most of the strain gauge are cheap and quite inexpensive
● Strain gauge are usually small so these are easy to handle.
Disadvantages:
● Strain gauges biggest disadvantage is that they are non-linear.
● It needs regular calibration in order to use perfectly and take perfect
reading.
● Highly Sensitive