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

Digital Logic and Micro controller

digital logic and Microcontroller notes
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Digital Logic and Micro controller

digital logic and Microcontroller notes
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 88

I.

ENVIRONMENTAL SENSORS

A. DHT11 and DHT22


The DHT11 and DHT22 are popular humidity and temperature sensors due to their
simplicity, low cost, and effectiveness. Both sensors have integrated digital output,
making them easy to use with microcontrollers like Arduino, Raspberry Pi, and
ESP32.

How They Work


1. Temperature Measurement:
o The sensors use a thermistor (a temperature-sensitive resistor) to
measure temperature. The resistance of the thermistor changes with
temperature, and the sensor’s internal circuitry converts this into a
digital signal.
2. Humidity Measurement:
o A capacitive humidity sensor is used. It consists of two electrodes
with a substrate between them that absorbs water vapor from the air.
The capacitance between the electrodes changes as the humidity
varies. This change is converted into a digital signal.
3. Data Communication:
o Both sensors communicate using a single-wire protocol, which
simplifies wiring. They send temperature and humidity data in a
structured packet that can be easily read by a microcontroller.

Key Differences Between DHT11 and DHT22

Feature DHT11 DHT22


Temperature Range 0°C to 50°C -40°C to 80°C
Humidity Range 20% to 90% 0% to 100%
Accuracy ±2°C, ±5% RH ±0.5°C, ±2% RH
Sampling Rate 1 Hz (once per second) 0.5 Hz (once every 2 sec)
Cost Cheaper Slightly more expensive
Size Smaller Slightly larger

Applications
1. Weather Stations: These sensors are used to collect environmental data
such as temperature and humidity for personal weather stations.
2. HVAC Systems: They help monitor and control indoor climate.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 1
3. Greenhouses: Used to maintain optimal growing conditions by tracking
temperature and humidity.
4. IoT Applications: Integrated into smart devices for home automation.
5. Health Monitoring Devices: Used in systems where maintaining a specific
humidity and temperature is crucial.

Advantages
 Ease of Use: Single-wire communication protocol simplifies wiring.
 Low Power Consumption: Suitable for battery-operated devices.
 Compact Size: Fits easily into small projects.

Limitations
 DHT11: Limited range and lower accuracy make it unsuitable for high-
precision applications.
 DHT22: Slower sampling rate means it's not ideal for real-time or fast-
changing environments.

Diagram

B. DS18B20 Temperature Sensor


The DS18B20 is a digital temperature sensor that provides precise measurements
and is widely used in embedded systems. Unlike analog sensors, the DS18B20

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 2
outputs temperature as a digital value, eliminating the need for analog-to-digital
conversion.
How It Works
1. Temperature Sensing Element:
o The DS18B20 uses a silicon-based sensing element to measure
temperature. It is embedded within the sensor package and converts
thermal changes into an electrical signal.
2. 1-Wire Protocol:
o This sensor communicates using the 1-Wire protocol, which requires
only a single data line (plus ground) to transmit information. This
simplifies wiring and allows multiple sensors to share the same data
line.
3. Digital Output:
o The sensor outputs temperature readings directly in a digital format
(Celsius by default) with a precision of up to 12 bits. This eliminates
noise issues common with analog sensors.
Specifications

Feature Specification
Temperature Range -55°C to +125°C
Accuracy ±0.5°C (between -10°C and +85°C)
Resolution Configurable from 9 to 12 bits
Power Supply 3.0V to 5.5V
Interface 1-Wire Protocol

Applications
1. Cold Chain Monitoring: Tracks temperature in refrigerators and freezers.
2. Industrial Systems: Monitors machinery to ensure they operate within safe
temperature ranges.
3. Weather Stations: Provides precise environmental temperature data.
4. IoT Devices: Used in smart home systems for climate monitoring.

Advantages
 High Precision: Accurate temperature readings up to ±0.5°C.
 Simplicity: Digital output makes it easy to interface with microcontrollers.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 3
 Multiple Sensors on One Bus: The unique 64-bit serial number for each
sensor allows multiple DS18B20 sensors to be connected to the same data
line.

Limitations
 Slow Sampling Rate: Reading temperatures at maximum resolution can
take up to 750ms.
 Limited Temperature Range: While adequate for most applications, it may
not suit extreme industrial conditions beyond its range.

Diagram

C. LM35, LM335 and LM34 Temperature Sensors


The LM35, LM335, and LM34 are all analog temperature sensors produced by
Texas Instruments, known for their simplicity, accuracy, and direct analog output
proportional to temperature. They differ mainly in their calibration and output
format.

1. LM35
LM35 is a precision temperature sensor with an analog voltage output linearly
proportional to the temperature in Celsius (°C).

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 4
How It Works
 It generates a voltage directly proportional to the temperature in °C.
 The output increases by 10 mV per degree Celsius.
 For example:
o At 25°C, the output is 250 mV.

o At 0°C, the output is 0 mV.

Specifications

Feature Value
Temperature Range -55°C to +150°C
Output 10 mV/°C
Accuracy ±0.5°C (at room temp)
Power Supply 4V to 30V

Applications
 HVAC systems
 Battery temperature monitoring
 Embedded systems requiring Celsius temperature readings

2. LM335
LM335 is similar to the LM35 but outputs a voltage proportional to the absolute
temperature in Kelvin (K).
How It Works
 The output is scaled to 10 mV per Kelvin.
 To convert to Celsius
T(°C)=T(K)−273.15T(°C) = T(K) - 273.15T(°C)=T(K)−273.15.
 For example,
o At 300 K (room temperature), the output is 3.00 V.

o At 0 K (absolute zero), the output is 0 V.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 5
Specifications

Feature Value
Temperature Range -40°C to +100°C
Output 10 mV/K
Accuracy ±1°C
Power Supply 4V to 30V

Applications
 Scientific experiments requiring Kelvin temperature scale
 Precision temperature monitoring in physics labs

3. LM34
LM34 outputs a voltage proportional to temperature in Fahrenheit (°F).
How It Works
 The output increases by 10 mV per degree Fahrenheit.
 For example:
o At 77°F (25°C), the output is 0.77 V.

o At 32°F (0°C), the output is 0.32 V.

Specifications

Feature Value
Temperature Range -50°F to +300°F
Output 10 mV/°F
Accuracy ±1°F
Power Supply 4V to 30V

Applications
 Systems where temperatures are conventionally measured in Fahrenheit
 Industrial environments in countries using Imperial units

Common Features
1. Ease of Use: No calibration required; direct proportional output.
2. Low Power Consumption: Ideal for battery-powered devices.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 6
3. Analog Output: Easy to interface with ADCs in microcontrollers.

Comparison Table

Sensor Temperature Scale Output Key Feature


LM35 Celsius (°C) 10 mV/°C Best for metric systems
LM335 Kelvin (K) 10 mV/K Absolute temperature
LM34 Fahrenheit (°F) 10 mV/°F Imperial systems

Diagram of Working Principle


1. Sensing Element: Detects temperature changes and converts them to
voltage.
2. Signal Conditioning: Amplifies and scales the output voltage based on the
sensor type.
3. Analog Output: Provides a continuous voltage signal proportional to the
temperature.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 7
D. K-Type Thermocouple with MAX6675 Amplifier
K-Type Thermocouple is a widely used temperature sensor known for its ability to
measure very high and low temperatures. It generates a voltage based on the
Seebeck Effect, where two dissimilar metals (Chromel and Alumel in the K-type)
produce a voltage when exposed to a temperature gradient.
The MAX6675 Amplifier is a dedicated integrated circuit designed to amplify and
convert the thermocouple’s analog signal into a digital output, making it easier to
interface with microcontrollers.

How It Works
K-Type Thermocouple
1. Seebeck Effect:
o The thermocouple consists of two different metals joined at one end
(the hot junction).
o The other ends (cold junction) are exposed to a reference temperature.

o A voltage proportional to the temperature difference between the hot


and cold junctions is generated.
2. Voltage Output:
o The voltage generated is very small (in the range of microvolts per
degree Celsius).
o For example:

 At 0°C: 0 mV
 At 100°C: ~4.1 mV
 At 500°C: ~20.6 mV
MAX6675 Amplifier
1. Signal Amplification:
o The MAX6675 amplifies the thermocouple’s tiny voltage output for
accurate reading.
2. Cold Junction Compensation:
o Thermocouple readings depend on the temperature of the cold
junction.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 8
o The MAX6675 includes a built-in temperature sensor to compensate for
changes in the cold junction temperature.
3. Digital Conversion:
o The MAX6675 converts the amplified signal into a 12-bit digital value.

o It communicates using the SPI protocol, ensuring compatibility with


most microcontrollers.

Specifications
K-Type Thermocouple

Feature Specification
Temperature Range -200°C to +1350°C
Material Chromel (+) and Alumel (-)
Accuracy ±1.5°C (typical)
Voltage Output ~41 µV/°C

MAX6675 Amplifier

Feature Specification
Temperature Range 0°C to 1024°C
Resolution 0.25°C
Interface SPI
Power Supply 3.0V to 5.5V

Applications
1. Industrial Monitoring:
o Measures furnace, kiln, or oven temperatures.

2. HVAC Systems:
o Monitors high-temperature ducts and pipes.

3. Scientific Research:
o Used in laboratories for high-temperature experiments.

4. 3D Printing:
o Monitors extruder and heated bed temperatures.

Advantages
1. Wide Temperature Range:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 9
o Can measure extreme temperatures, making it versatile.

2. Accuracy:
o The MAX6675 provides precise temperature readings with
compensation.
3. Digital Output:
o Simplifies integration with microcontrollers.

4. Durable:
o The K-Type thermocouple can withstand harsh conditions.

Limitations
1. Accuracy Limitation:
 ±2°C to ±5°C error for very high or low temperatures.
2. Limited Amplifier Range:
 The MAX6675 is restricted to 0°C–1024°C, while the K-Type
thermocouple itself can handle a broader range.
3. Cold Junction Dependency:
 Requires compensation for accurate readings.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 10
E. BME280 (Pressure, Temperature, and Humidity Sensor)
BME280 is a highly integrated environmental sensor that measures pressure,
temperature, and humidity in a compact package. It is widely used in IoT,
weather monitoring, and environmental sensing applications due to its low power
consumption, high accuracy, and versatility.

How It Works
1. Pressure Measurement:
o The BME280 uses a piezo-resistive sensing element to measure
atmospheric pressure.
o Changes in pressure cause tiny deflections in the diaphragm of the
sensor, altering the resistance. This change is converted into a precise
pressure value.
2. Temperature Measurement:
o A MEMS-based temperature sensor provides temperature readings,
which are also used for temperature compensation in pressure and
humidity measurements.
3. Humidity Measurement:
o A capacitive humidity sensor measures the relative humidity (RH).

o The sensor detects water vapor in the air by measuring changes in the
dielectric constant of the sensor's substrate.
4. Data Communication:
o The sensor communicates via I2C or SPI, making it easy to integrate
with microcontrollers.

Specifications

Feature Specification
Pressure Range 300 hPa to 1100 hPa
Temperature Range -40°C to +85°C
Humidity Range 0% to 100% RH
Accuracy (Pressure) ±1 hPa
Accuracy (Temp) ±0.5°C

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 11
Accuracy (Humidity) ±3% RH
Interface I2C or SPI
Power Consumption 3.6 µA (in sleep mode)

Applications
1. Weather Monitoring Stations:
o Tracks temperature, humidity, and atmospheric pressure for
forecasting.
2. Altimeters:
o Calculates altitude based on atmospheric pressure.

3. IoT Devices:
o Used in smart homes for indoor climate monitoring.

4. GPS Navigation:
o Enhances altitude accuracy in outdoor navigation systems.

5. Aviation:
o Measures pressure for altitude and weather data in flight instruments.

Advantages
1. Highly Integrated:
o Combines three environmental parameters in one device.

2. Compact Size:
o Ideal for portable and space-constrained applications.

3. Power-Efficient:
o Operates with minimal energy, suitable for battery-powered devices.

4. Versatile Communication:
o Compatible with I2C and SPI protocols.

Limitations
1. Environmental Constraints:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 12
o The sensor may degrade over time if exposed to water or
contaminants.
2. Limited Pressure Accuracy:
o ±1 hPa is sufficient for most applications but may not be suitable for
precision measurements like barometry.

3. Temperature Compensation Dependency:


o Requires accurate temperature data for optimal pressure and humidity
readings.

Diagram

Interfacing the BME280 with Microcontrollers


 I2C Mode:
o Connect SDA (Data) and SCL (Clock) pins to the microcontroller.

o Use a pull-up resistor (typically 4.7 kΩ) for I2C lines.

o Communicate using the sensor’s I2C address (default: 0x76 or 0x77).

 SPI Mode
o Use MOSI, MISO, SCK, and CS pins for communication

o Faster data transfer compared to I2C

Connections for BME280 in I2C Mode

BME280 Pin Arduino Pin Description


VIN 5V/3.3V Power supply (use 3.3V for some

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 13
models)
GND GND Ground connection
SCL A5 (Uno), D21 (Mega) I2C clock line
SDA A4 (Uno), D20 (Mega) I2C data line

F. BMP388 Altimeter (Pressure, Altitude, Temperature Sensor)


The BMP388 is a high-precision barometric pressure sensor designed for measuring
atmospheric pressure, altitude, and temperature. Manufactured by Bosch, it is
widely used in drones, weather stations, IoT devices, and navigation systems. With
its small size, low power consumption, and high accuracy, the BMP388 is an
excellent choice for portable and embedded systems.
How It Works
1. Pressure Measurement:
o The BMP388 uses a piezo-resistive sensing element to measure air
pressure. The element detects pressure changes by measuring small
deformations in its diaphragm and converts them into a voltage.
2. Temperature Measurement:
o The sensor incorporates a built-in temperature sensor, which not only
provides ambient temperature readings but also compensates for
temperature effects on pressure measurements.
3. Altitude Calculation:
o Based on the relationship between atmospheric pressure and altitude,
the BMP388 calculates the altitude above sea level
4. Communication:
o The BMP388 supports I2C and SPI interfaces, making it easy to
interface with most microcontrollers.
Specifications

Feature Specification
Pressure Range 300 hPa to 1250 hPa
Temperature Range -40°C to +85°C
Pressure Resolution 0.08 Pa
Altitude Resolution 0.2 meters
Temperature Accuracy ±0.5°C
Pressure Accuracy ±0.5 hPa

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 14
Interface I2C (up to 3.4 MHz) / SPI (up to 10 MHz)

Applications
1. Drones and UAVs:
o For accurate altitude control and flight stabilization.

2. Weather Stations:
o To monitor atmospheric pressure and temperature.

3. Navigation Systems:
o To enhance GPS accuracy with altitude data.

4. IoT and Wearable Devices:


o To track environmental conditions in smart devices.

5. Scientific Experiments:
o For pressure and altitude monitoring in lab setups.

Advantages
1. High Accuracy:
o Provides precise pressure and altitude readings.

2. Wide Pressure Range:


o Suitable for low-pressure (high-altitude) and high-pressure
environments.
3. Compact and Power-Efficient:
o Ideal for battery-operated and portable devices.

4. Dual Interfaces:
o Supports both I2C and SPI for versatile connectivity.

Limitations
1. Temperature Dependency:
o Although compensated, the sensor’s accuracy might drift slightly in
extreme temperatures.
2. Environmental Constraints:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 15
o Requires protection in environments with high humidity, water
exposure, or dust.
3. Altitude Calculation Assumptions:
o Assumes a standard atmospheric model, which may cause errors in
non-standard conditions.
Interfacing BMP388 with Arduino
Connections (I2C Mode)

BMP388 Pin Arduino Pin Description


VIN 5V/3.3V Power supply.
GND GND Ground.
SCL A5 (Uno), D21 (Mega) I2C clock.
SDA A4 (Uno), D20 (Mega) I2C data.

Applications and Use Cases


1. Weather Forecasting:
 Combines real-time pressure, temperature, and altitude data for
weather prediction.
2. Altitude Hold for Drones:
 Maintains stable altitude during flight.
3. Smart Devices:
 Tracks environmental changes in smartwatches and fitness bands.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 16
G. MQ Sensors
MQ sensors are a series of gas sensors that detect the presence and concentration
of various gases in the air. These sensors are widely used in safety systems,
environmental monitoring, and industrial applications due to their affordability, ease
of use, and versatility.

How They Work


MQ sensors use a metal oxide semiconductor (MOS) to sense gas concentration.
The operational principle is as follows:
1. Sensing Element:
o The sensor has a heated tin dioxide (SnO₂) sensing layer.

o In the presence of gas, the resistance of this layer changes depending


on the gas concentration.
2. Gas Detection:
o The change in resistance is converted into a corresponding voltage
using a built-in voltage divider.
3. Output:
o Provides an analog signal proportional to the gas concentration.

o Some models also provide a digital signal using a comparator.

Common MQ Sensors and Their Target Gases

MQ Sensor Detects Typical Gases Sensitivity Range (ppm)


Flammable gases LPG, Methane, 300 - 10,000
MQ-2
Propane, Hydrogen
Alcohol Ethanol, Methanol, 0.04 - 4
MQ-3
Benzine
MQ-4 Methane Methane, Natural Gas 200 - 10,000
LPG and Natural Gas LPG, Methane, 200 - 10,000
MQ-5
Hydrogen
MQ-6 LPG LPG, Butane, Propane 200 - 10,000

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 17
MQ-7 Carbon Monoxide CO 20 - 2,000
MQ-8 Hydrogen Hydrogen 100 - 10,000
MQ-9 Carbon Monoxide and Methane CO, Methane 10 - 10,000
Air Quality Ammonia, Alcohol, 10 - 1,000
MQ-135
Benzene, Smoke

Specifications

Feature Specification
Operating Voltage 5V
Output Analog and Digital (via Comparator)
Preheat Time 20–60 seconds
Response Time < 10 seconds
Operating Temperature -20°C to +50°C
Lifespan ~2 years

Applications
1. Gas Leak Detection:
o MQ-2, MQ-5, and MQ-6 for LPG or methane leaks.

2. Breath Analyzers:
o MQ-3 for alcohol detection.

3. Air Quality Monitoring:


o MQ-135 for detecting harmful gases in the environment.

4. Fire Safety:
o MQ-2 and MQ-7 for smoke and CO detection.

5. Industrial Monitoring:
o To ensure safe levels of specific gases.

Advantages
1. Affordable and Versatile:
o Available for detecting a wide range of gases.

2. Simple Integration:
o Easy to use with microcontrollers.

3. Fast Response Time:


o Reacts quickly to changes in gas concentration.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 18
Limitations
1. Heater Power Consumption:
o Requires continuous heating, which increases power consumption.

2. Environmental Sensitivity:
o May provide inaccurate readings in high humidity or fluctuating
temperatures.
3. Calibration Requirement:
o Must be calibrated for precise measurements.

4. Limited Lifespan:
o The sensing element degrades over time.

Interfacing an MQ Sensor with Arduino


Connections

MQ Sensor Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
AOUT A0 Analog output signal.
DOUT Digital Pin Digital output (optional).

Example: MQ-2 for Smoke Detection


 Gas: LPG, Methane, Hydrogen, Smoke.
 Typical Threshold: Adjust the potentiometer to set the digital output
threshold.
 Use analog values for real-time concentration tracking.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 19
H. FC-37 or YL-83 Rain Sensor
The FC-37 and YL-83 Rain Sensors are simple and effective tools for detecting
rain or water presence. These sensors are widely used in weather monitoring
systems, automatic wipers, smart irrigation systems, and outdoor IoT projects. The
sensor consists of a rain detection module and a control module with an onboard
comparator.
How It Works
1. Rain Detection Plate:
o The rain detection plate is a PCB with conductive traces. When water
droplets fall on it, they form a conductive path between the traces,
decreasing resistance.
2. Signal Generation:
o The change in resistance modifies the voltage output, which is
interpreted as rain presence and intensity.
3. Control Module:
o The sensor control module uses an LM393 comparator to generate a
digital output (HIGH/LOW) based on a threshold set using a
potentiometer.
o The module also provides an analog output for precise monitoring of
water intensity.

Specifications

Feature Specification
Operating Voltage 3.3V - 5V
Output Digital (HIGH/LOW) and Analog (0-5V)
Dimensions ~30mm x 50mm
Operating Temperature -40°C to +85°C
Control Module Chip LM393 Comparator

Applications
1. Weather Stations:
o Detect rain to monitor weather conditions.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 20
2. Automatic Wiper Systems:
o Trigger wipers in vehicles when rain is detected.

3. Smart Irrigation:
o Delay watering when rain is detected.

4. IoT Projects:
o Integrate into outdoor sensors for water presence detection.

Advantages
1. Simple and Reliable:
o Easy to use with minimal external components.

2. Dual Outputs:
o Provides both digital and analog signals for flexible use.

3. Adjustable Sensitivity:
o Potentiometer allows threshold customization for rain intensity.

Limitations
1. Corrosion:
o The rain detection plate is prone to corrosion if not coated or
maintained.
2. Limited Precision:
o Cannot differentiate between light and heavy rain without calibration.

3. Environmental Sensitivity:
o False positives can occur due to condensation or dew.

Interfacing FC-37/YL-83 with Arduino


Connections

FC-37/YL-83 Pin Arduino Pin Description

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 21
VCC 5V Power supply.
GND GND Ground connection.
DO (Digital) D2 Digital output for rain detection.
AO (Analog) A0 Analog output for rain intensity.

Diagram: FC-37/YL-83 Rain Sensor

Applications in Real-Life Projects


1. Home Automation:
o Activate alerts when it starts raining.

2. Vehicle Safety:
o Trigger rain sensors to improve wiper response in real time.

3. Agriculture:
o Monitor rainfall to optimize irrigation schedules.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 22
I. YL-69 or HL-69 Soil Moisture Sensor
The YL-69 and HL-69 Soil Moisture Sensors are affordable and effective tools for
monitoring soil moisture levels. These sensors are widely used in agriculture,
gardening, and environmental monitoring projects. The sensor consists of a
moisture-detection probe and a control module with an onboard comparator.

How It Works
1. Moisture Detection Probe:
o The probe has two electrodes that are inserted into the soil.

o When the soil is moist, it conducts electricity better, resulting in lower


resistance.
o When the soil is dry, resistance increases.

2. Signal Generation:
o The control module converts the resistance into a corresponding
voltage signal.
3. Control Module:
o Equipped with an LM393 comparator to provide both analog and
digital outputs.
o A potentiometer adjusts the digital output threshold.

Specifications

Feature Specification
Operating Voltage 3.3V - 5V
Output Analog (0-5V) and Digital (HIGH/LOW)
Probe Dimensions ~60mm x 20mm
Control Module Chip LM393 Comparator
Operating Temperature 10°C - 50°C

Applications
1. Smart Irrigation Systems:
o Automate watering based on soil moisture levels.

2. Environmental Monitoring:
o Monitor soil conditions in gardens or farmlands.

3. IoT Projects:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 23
o Integrate into smart devices for soil health tracking.

4. Greenhouses:
o Ensure optimal moisture levels for plant growth.

Advantages
1. Affordable:
o Low-cost solution for moisture detection.

2. Dual Outputs:
o Both digital and analog signals for flexible use.

3. Easy to Integrate:
o Works seamlessly with microcontrollers like Arduino or Raspberry Pi.

Limitations
1. Corrosion:
o The electrodes can corrode over time if left in soil continuously.

2. Environmental Sensitivity:
o Prone to errors in highly conductive soils or extreme conditions.

3. Limited Lifespan:
o Frequent cleaning and maintenance are required for accuracy.

Interfacing YL-69/HL-69 with Arduino


Connections

YL-69/HL-69 Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
AO (Analog) A0 Analog output for moisture level.
DO (Digital) D2 Digital output for threshold.

Diagram: YL-69 Soil Moisture Sensor

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 24
1. Probe:
o Two metal electrodes detect soil moisture through resistance changes.

2. Control Module:
o LM393 comparator for digital threshold output.

o Potentiometer to adjust the threshold level.

Applications in Real-Life Projects


1. Automated Plant Watering System:
o Turn on/off a water pump based on soil moisture levels

2. Weather Monitoring Station:


o Combine with other sensors to measure environmental conditions

3. Smart Greenhouses:
o Automate climate and soil moisture control for optimal plant health

Diagram

II. MOTION BASED SENSORS

A. PIR Motion Sensor


A PIR (Passive Infrared) Motion Sensor detects motion by sensing changes in
infrared radiation in its environment. PIR sensors are widely used in security

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 25
systems, home automation, lighting systems, and other applications where motion
detection is required.
How It Works
1. Infrared Radiation:
o All objects emit infrared (IR) radiation based on their temperature.

o The PIR sensor detects these IR emissions.

2. Dual Sensing Elements:


o The sensor has two IR-sensitive slots.

o When no motion occurs, both slots detect the same IR level.

o When motion occurs, a change in IR levels between the two slots


generates a signal.
3. Signal Processing:
o The output signal is amplified and filtered, producing a HIGH (motion
detected) or LOW (no motion) digital output.

Specifications

Feature Specification
Operating Voltage 4.5V – 20V (commonly 5V)
Output Digital (HIGH/LOW)
Detection Range ~5m – 12m (depending on model)
Detection Angle ~110° to 120°
Delay Time Adjustable (0.3s to 5min, typical)
Trigger Modes Single Trigger / Continuous Trigger

Key Components of a PIR Sensor


1. Pyroelectric Sensor:
o Detects changes in IR radiation.

2. Fresnel Lens:
o Focuses infrared radiation onto the sensor.

o Expands the detection area.

3. Amplifier and Comparator Circuit:


o Processes the signal from the pyroelectric sensor.

4. Potentiometers:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 26
o Adjust the detection sensitivity and delay time.

Applications
1. Security Systems:
 Detect intrusions and trigger alarms or notifications.
2. Automatic Lighting:
 Turn lights on/off based on motion detection.
3. Energy Conservation:
 Automatically turn off appliances in unoccupied areas.
4. Home Automation:
 Trigger smart devices when motion is detected.
5. Robotics:
 Detect nearby obstacles or moving objects.

Advantages
1. Low Power Consumption:
o Ideal for battery-operated devices.

2. Reliable and Inexpensive:


o Affordable for mass deployment.

3. Wide Detection Area:


o Covers large spaces effectively.

Limitations
1. Environmental Sensitivity:
o Heat sources like sunlight or heaters can cause false triggers.

2. No Object Identification:
o Cannot differentiate between objects.

3. Limited Detection Distance:


o Affected by obstacles like walls or partitions.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 27
Interfacing PIR Sensor with Arduino
Connections

PIR Sensor Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
OUT D2 Digital output signal.

Trigger Modes
1. Single Trigger Mode:
o The sensor sends a HIGH signal once when motion is detected, then
LOW after the delay time.
o Ideal for simple on/off actions.

2. Continuous Trigger Mode:


o The sensor remains HIGH as long as motion is detected.

o Useful for continuous actions like keeping a light on while someone is


in a room.

Adjustments
1. Sensitivity:
o Adjust using the potentiometer to modify the detection range.

2. Delay Time:
o Set the time the output stays HIGH after detecting motion.

Diagram: PIR Sensor Detection

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 28
Applications in Real-Life Projects
1. Motion-Activated Lights:
o Automatically turn on lights when someone enters a room.

2. Home Security System:


o Trigger alarms or cameras when movement is detected.

3. Energy-Saving Systems:
o Switch off unused appliances in unoccupied areas.

B. HC-SR04 Ultrasonic Sensor


The HC-SR04 Ultrasonic Sensor is a widely used sensor for measuring distance. It
employs ultrasonic waves to calculate the distance to an object by measuring the
time taken for a sound wave to travel to and from the object. This sensor is
commonly used in robotics, obstacle detection, automation, and IoT projects.
How It Works
1. Ultrasonic Waves:
o The sensor emits high-frequency sound waves (40 kHz) through its
transmitter.
2. Reflection:
o When the sound wave hits an object, it reflects back.

3. Echo Detection:
o The sensor's receiver detects the returning wave and calculates the
time taken for the round trip.
4. Distance Calculation:
o Using the formula

Speed of Sound ×Time


Distance =
2
(The division by 2 accounts for the round trip.)

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 29
Specifications

Feature Specification
Operating Voltage 5V
Operating Current <15mA
Operating Frequency 40 kHz
Measurement Range 2 cm – 400 cm
Accuracy ±3 mm
Trigger Pulse Width 10 µs
Output Digital pulse proportional to distance
Operating Temperature -15°C to +70°C

Applications
1. Robotics:
o Obstacle detection and avoidance.

2. Automation Systems:
o Measure liquid levels in tanks or detect objects.

3. IoT Projects:
o Integrate into smart devices for distance monitoring.

4. Parking Assistance:
o Detect proximity to obstacles in vehicles.

5. Security Systems:
o Monitor restricted areas for movement or presence.

Advantages
1. Non-Contact Measurement:
o Measures distance without physical contact.

2. Affordable:
o Cost-effective for various applications.

3. Wide Range:
o Covers distances from 2 cm to 4 meters.

4. Simple Interfacing:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 30
o Works easily with microcontrollers like Arduino.

Limitations
1. Environmental Sensitivity:
o Performance is affected by temperature and humidity.

2. Hard Surfaces:
o Reflects better from flat surfaces than irregular ones.

3. Dead Zone:
o Unable to detect objects closer than 2 cm.

Interfacing HC-SR04 with Arduino


Connections

HC-SR04 Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
TRIG D9 Trigger pin to send ultrasonic pulses.
ECHO D10 Echo pin to receive reflected signals.

Operating Principle Diagram


1. Trigger Pin:
o Sends an ultrasonic pulse (40 kHz).

2. Echo Pin:
o Receives the reflected pulse.

3. Calculation:
o The time difference is used to compute the distance.

Calibration and Considerations


1. Temperature:
o The speed of sound changes with temperature. For more accurate
measurements, compensate for ambient temperature
2. Surface Type:
o Highly reflective surfaces give better results.

o Avoid soft or irregular surfaces, which may scatter sound waves.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 31
3. Positioning:
o Place the sensor perpendicular to the surface for optimal detection.

Applications in Real-Life Projects


1. Obstacle Avoidance Robot:
o Mount the HC-SR04 on a servo to scan the environment.

2. Liquid Level Monitoring:


o Measure water level in a tank without direct contact.

3. Parking Sensors:
o Alert users of nearby obstacles while parking vehicles.

Diagram

C. MPU6050 Accelerometer and Gyroscope


The MPU6050 is a 6-axis IMU (Inertial Measurement Unit) sensor that combines a
3-axis accelerometer and a 3-axis gyroscope in a single module. It is widely
used in motion-tracking applications, including robotics, drones, gaming devices,
and wearable technology. The sensor can measure acceleration, angular velocity,
and with proper processing, calculate orientation.

How It Works
1. Accelerometer:
o Measures linear acceleration (g-force) along three axes: X, Y, and Z.

o Useful for detecting tilt, free-fall, or vibration.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 32
2. Gyroscope:
o Measures angular velocity (rate of rotation) in degrees per second (°/s)
along three axes: X, Y, and Z.
o Ideal for tracking rotational motion.

3. DMP (Digital Motion Processor):


o Onboard processor for motion fusion algorithms, reducing the need for
external computation.
o Can compute orientation (roll, pitch, yaw).

4. I²C Communication:
o Data is transmitted via the I²C protocol for easy integration with
microcontrollers.

Specifications

Feature Specification
Operating Voltage 3.3V – 5V
Communication Protocol I²C (default address: 0x68)
Accelerometer Range ±2g, ±4g, ±8g, ±16g
Gyroscope Range ±250, ±500, ±1000, ±2000 °/s
Power Consumption ~3.6mA
Sampling Rate Up to 1 kHz
Operating Temperature -40°C to +85°C

Applications
1. Drones:
o Stabilization and orientation control.

2. Robotics:
o Balance control (e.g., self-balancing robots).

3. Wearables:
o Fitness trackers or smartwatches for motion sensing.

4. Gaming Devices:
o Motion controllers for immersive gameplay.

5. Gesture Recognition:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 33
o Detecting and interpreting hand movements.

Advantages
1. Compact and Lightweight:
o Combines accelerometer and gyroscope in a small package.

2. High Sensitivity:
o Accurate motion and orientation detection.

3. Integrated DMP:
o Offloads computational work from the microcontroller.

Limitations
1. Temperature Drift:
o Requires calibration for consistent results in varying environments.

2. Noise Sensitivity:
o Outputs raw data that may need filtering.

3. Complex Calibration:
o Requires algorithms for precise orientation computation.

Interfacing MPU6050 with Arduino


Connections

MPU6050 Pin Arduino Pin Description


VCC 3.3V/5V Power supply.
GND GND Ground connection.
SCL A5 (Uno) or D21 (ESP32) I²C Clock line.
SDA A4 (Uno) or D22 (ESP32) I²C Data line.

Applications in Real-Life Projects


1. Self-Balancing Robot:
o Use accelerometer and gyroscope data for balancing calculations.

2. Drone Stabilization:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 34
o Process sensor data to maintain steady flight.

3. Gesture-Controlled Devices:
o Detect hand motions for controlling gadgets or robots.

Diagram

III. OTHER SENSORS/MODULES/PERIPHERALS

A. DS1307 and DS3231 Real Time Clock (RTC) Modules


The DS1307 and DS3231 are popular Real Time Clock (RTC) modules that keep
track of time and date even when the main system is powered off. They use a
backup battery to retain data and are widely used in applications requiring accurate
and consistent timekeeping.

Differences Between DS1307 and DS3231

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 35
Feature DS1307 DS3231
Accuracy ±2 seconds/day ±2 ppm (±0.1728 seconds/day) due
(uncompensated) to temperature compensation
Temperature Compensation No Yes
Operating Voltage 4.5V–5.5V 2.3V–5.5V
Battery Voltage 3.3V (typical CR2032) 3.3V (typical CR2032)
Temperature Range 0°C to +70°C -40°C to +85°C
Additional Features Basic RTC Integrated temperature sensor,
alarms, and 32 kHz output

Core Features
1. Timekeeping:
o Tracks seconds, minutes, hours, day, date, month, and year.

o Automatic leap year compensation up to 2100.

2. Backup Battery Support:


o Operates on a coin-cell battery during power outages, maintaining
time data.
3. Communication:
o Uses I²C (Inter-Integrated Circuit) protocol for interfacing.

4. Programmable Alarms (DS3231 only):


o Alarm functionality for scheduling events or waking up systems.

5. Temperature Sensor (DS3231 only):


o Internal sensor to provide additional temperature data.

Applications
1. Data Logging:
o Timestamp measurements from sensors in IoT applications.

2. Automation:
o Scheduled tasks such as turning devices on/off at specific times.

3. Clocks:
o Create digital clocks for homes, vehicles, or industrial use.

4. Reminder Systems:
o Trigger alarms for time-sensitive processes.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 36
5. Wearables:
o Timekeeping in smartwatches and fitness trackers.

Specifications
DS1307

Feature Specification
Operating Voltage 4.5V–5.5V
Time Format 12-hour/24-hour
Battery Backup Yes (CR2032 coin cell)
I²C Address 0x68
Power Consumption ~500 nA during battery backup

DS3231

Feature Specification
Operating Voltage 2.3V–5.5V
Temperature Accuracy ±3°C (typical)
Alarm Capability Yes, two programmable alarms
Temperature Sensor Integrated
I²C Address 0x68

Advantages
1. DS1307:
o Simple and affordable.

o Reliable for basic timekeeping in controlled environments.

2. DS3231:
o High accuracy with temperature compensation.

o Suitable for extreme conditions or precision-critical applications.

Limitations
1. DS1307:
o Loses accuracy over time, especially in varying temperatures.

o Requires a steady 5V supply for optimal performance.

2. DS3231:
o Higher cost compared to DS1307.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 37
Interfacing DS1307/DS3231 with Arduino
Connections

RTC Pin Arduino Pin Description


VCC 5V/3.3V Power supply.
GND GND Ground connection.
SCL A5 (Uno) or D21 (ESP32) I²C Clock line.
SDA A4 (Uno) or D22 (ESP32) I²C Data line.

Applications in Real-Life Projects


1. Smart Irrigation:
o Use RTC to water plants at specific times.

2. Data Logger:
o Record temperature, humidity, or other sensor readings with
timestamps.
3. Alarms:
o Set programmable alarms using DS3231 for precise scheduling.

4. Event-Based Systems:
o Activate processes based on specific times.

Diagrams

B. Load Cell with HX711 Amplifier

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 38
A load cell is a transducer that converts force (or weight) into an electrical signal.
The signal is typically very small, requiring amplification and conversion into a
digital format. This is achieved using the HX711 amplifier module, which is a
precise 24-bit ADC (Analog-to-Digital Converter) designed for weight measurement.
The combination of a load cell and HX711 is widely used in electronic weighing
scales, industrial force measurement systems, and IoT projects requiring weight or
pressure sensing.

How It Works
1. Load Cell:
o Contains strain gauges bonded to a flexible structure. When weight
or force is applied, the strain gauge's resistance changes
proportionally.
o The resistance change causes a small voltage difference, which is the
raw signal.
2. HX711 Amplifier:
o Amplifies the small voltage from the load cell.

o Converts the amplified analog signal into a digital signal using a 24-bit
ADC.
o Transmits the digital data to a microcontroller via a serial interface.

Specifications
Load Cell:

Feature Specification
Material Aluminum or Steel
Rated Load Varies (e.g., 5kg, 10kg, 50kg, etc.)
Sensitivity ~2mV/V
Excitation Voltage 5V to 10V
Output Resistance 350Ω

HX711 Amplifier

Feature Specification
Operating Voltage 2.6V–5.5V
ADC Resolution 24-bit

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 39
Input Channels 2 (A and B)
Gain Options 32, 64, 128
Interface Serial (Clock and Data)

Applications
1. Weighing Scales:
o Household, industrial, or precision scales.

2. Force Measurement:
o Measure force in machines or robotic grippers.

3. IoT Applications:
o Smart weighing systems or inventory monitoring.

4. Process Automation:
o Weight-based quality control in manufacturing.

Advantages
1. High Accuracy:
o 24-bit resolution provides precise weight readings.

2. Compact Design:
o Easy to integrate into systems.

3. Low Power Consumption:


o Ideal for battery-operated devices.

Limitations
1. Environmental Factors:
o Temperature changes can affect accuracy; compensation may be
needed.
2. Sensitivity to Noise:
o Shielded cables and proper grounding are required for reliable
readings.
3. Calibration Requirement:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 40
o Must be calibrated for consistent and accurate measurements.

Interfacing Load Cell and HX711 with Arduino


Connections

HX711 Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
DT D3 Data line (output).
SCK D2 Clock line.
E+ Load Cell Red Excitation positive terminal.
E- Load Cell Black Excitation negative terminal.
A+ Load Cell Green Signal positive terminal.
A- Load Cell White Signal negative terminal.

Diagram

Applications in Real-Life Projects


1. Smart Scale:
o Combine with Wi-Fi or Bluetooth modules for IoT weight tracking.

2. Robotics:
o Measure the force exerted by robotic arms or grippers.

3. Quality Control:
o Ensure precise ingredient weights in food or chemical production.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 41
C. Fingerprint Sensor Module (FPM10A)
The FPM10A is a compact fingerprint sensor module capable of capturing, storing,
and matching fingerprints. It is widely used in security systems like door locks,
safes, and attendance systems. The module integrates a fingerprint scanner and an
onboard DSP (Digital Signal Processor) to process captured images.
How It Works
1. Image Capture:
o The sensor scans the ridges and valleys of a finger to create a high-
resolution image.
2. Feature Extraction:
o The module processes the image to extract unique features called
minutiae.
3. Storage:
o Extracted fingerprint templates are stored in the module's internal
memory.
4. Matching:
o During verification, the module compares the newly scanned
fingerprint with stored templates to determine a match.

Features
1. Onboard Processing:
o The FPM10A handles image processing, feature extraction, and
template matching internally, reducing the workload on the
microcontroller.
2. Storage Capacity:
o Stores up to 1000 fingerprint templates in its flash memory.

3. Communication:
o Supports UART (TX/RX) for interfacing with microcontrollers like
Arduino, ESP32, or Raspberry Pi.
4. Two Modes of Operation:
o Enrolling Mode: Add new fingerprints to the module.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 42
o Verification Mode: Match a fingerprint against stored templates.

Specifications

Feature Specification
Operating Voltage 3.6V–6V
Current Consumption <100mA
Interface UART (TTL Logic)
Image Resolution 500 DPI
Storage Capacity 1000 fingerprints
Verification Speed <1 second
Module Size 56mm x 20mm x 21.5mm

Applications
1. Access Control Systems:
o Secure doors, lockers, or safes using fingerprint authentication.

2. Attendance Systems:
o Automate attendance logging in schools, offices, and factories.

3. IoT Security:
o Add biometric security to IoT devices like smart home systems.

4. Embedded Devices:
o Integrate into robotics or DIY electronics projects.

Advantages
1. High Security:
o Fingerprints provide a unique and non-replicable method of
authentication.
2. Compact and Standalone:
o The module can function independently without requiring external
image processing.
3. Ease of Integration:
o UART communication simplifies connections with popular
microcontrollers.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 43
Limitations
1. Environmental Sensitivity:
o Moist or dirty fingers may reduce the sensor's effectiveness.

2. Limited Memory:
o Only supports up to 1000 templates; not suitable for large-scale
systems.
3. Dependency on Physical Contact:
o Cannot be used for remote biometric verification.

Interfacing FPM10A with Arduino


Connections

FPM10A Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
TX D3 Data transmission (to Arduino RX).
RX D2 Data reception (from Arduino TX).
Applications in Real-Life Projects
1. Smart Lock:
o Unlock doors or safes using fingerprints.

2. Secure Device Control:


o Start a robot or a machine only with authorized fingerprints.

3. Personalized Gadgets:
o Configure custom actions for specific users based on fingerprint IDs.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 44
IV. DISPLAYS

A. OLED Display
An OLED (Organic Light Emitting Diode) display is a type of flat-panel display
that uses organic compounds to emit light when electricity is applied. Unlike
traditional LCDs (Liquid Crystal Displays), OLEDs do not require a backlight, as each
pixel emits its own light. This results in better contrast, thinner panels, and lower
power consumption. OLEDs are used in a wide range of applications, including
smartphones, TVs, wearables, and embedded systems.
How It Works
1. Organic Materials:
o The display is composed of organic compounds that emit light when
current passes through them.
2. Pixels:
o Each pixel in an OLED display consists of a combination of red, green,
and blue OLED materials, allowing for full-color display capabilities.
3. Electrodes:
o OLED displays use two electrodes: one is transparent (for the top
layer), and the other is opaque (for the bottom layer), facilitating
current flow through the organic materials.
4. Emitting Light:
o When voltage is applied, the organic materials emit light directly,
allowing each pixel to glow without the need for an external backlight.

Types of OLED Displays


1. Passive Matrix OLED (PMOLED):
o Simple, low-resolution displays, typically used in low-power devices like
smartwatches or small IoT projects.
2. Active Matrix OLED (AMOLED):
o More complex and used in high-definition displays like smartphones,
TVs, and large screens. AMOLED uses thin-film transistors (TFTs) to
control each pixel individually, allowing for faster refresh rates and
better image quality.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 45
Specifications of Common OLED Displays
0.96-inch OLED Display (most commonly used in Arduino projects)

Feature Specification
Display Size 0.96 inches
Resolution 128x64 pixels
Color Depth Monochrome (Black and White)
Communication I²C (or SPI, depending on module)
Operating Voltage 3.3V–5V
Power Consumption Low power, typically <20mA
Dimensions 27.5mm x 27.5mm x 4mm

Applications
1. Wearables:
o OLEDs are commonly used in fitness trackers and smartwatches due to
their low power consumption and compact size.
2. Embedded Systems:
o Used in Arduino-based projects, IoT devices, and robotics to display
sensor data, status, or feedback to users.
3. Displays in Consumer Electronics:
o In smartphones, TVs, and laptops for their vibrant colors, deep blacks,
and energy-efficient properties.
4. Automotive:
o OLEDs are becoming popular for dashboards, infotainment systems,
and heads-up displays in vehicles.

Advantages of OLED Displays


1. High Contrast and Brightness:
o OLEDs can achieve true blacks since pixels turn off completely, offering
high contrast ratios compared to LCDs.
2. Low Power Consumption:
o Since OLED pixels emit light only when required, they consume less
power, especially when displaying darker images.
3. Thin and Flexible:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 46
o OLED displays can be made thinner and more flexible than LCDs,
allowing for curved or foldable screens.
4. Wide Viewing Angles:
o OLED displays have wider viewing angles than traditional LCDs, with
no color distortion or brightness loss.

Limitations of OLED Displays


1. Cost:
o OLED technology is more expensive than traditional LCDs, which can
increase the overall cost of the device.
2. Burn-in Issue:
o Prolonged display of static images may cause pixel burn-in, leading to
permanent ghost images on the screen. This is less of an issue in
smaller, low-power applications like embedded systems, but it’s more
of a concern in larger displays.
3. Lifespan:
o OLED displays, particularly blue OLEDs, tend to have a shorter lifespan
compared to LCDs.

Interfacing OLED Display with Arduino


Wiring (I²C Interface)

OLED Pin Arduino Pin Description


VCC 5V Power supply.
GND GND Ground connection.
SCL A5 Clock line (SCL).
SDA A4 Data line (SDA).

Applications in Real-Life Projects


1. Weather Station:
o Display temperature, humidity, and pressure readings from sensors on
an OLED screen.
2. Sensor Display:
o Show real-time data like light intensity, temperature, or motion on
embedded systems.
3. Clock:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 47
o Build a simple digital clock that shows current time using an RTC (Real-
Time Clock) module and display it on the OLED.
4. Smart Devices:
o Display statuses like battery level, network connection, or user inputs.

Diagram

B. 8x8 Dot Matrix


An 8x8 Dot Matrix Display is a type of visual output device that consists of 64
individual LEDs arranged in a grid of 8 rows and 8 columns. These LEDs can be
individually controlled, allowing the display of various patterns, characters, and
even basic graphics. Dot matrix displays are commonly used in embedded systems,
clocks, scrolling text displays, and various other applications where a visual output
is needed.
How It Works
1. Grid Layout:
 The display consists of 64 LEDs arranged in an 8x8 matrix, which can
represent text, simple images, or animations by illuminating specific
LEDs.
 Each LED is controlled via a row and column, and the combination of
active row and column determines which LED lights up.
2. Multiplexing:
 Since all 64 LEDs cannot be powered at once (due to power
limitations), the display uses a technique called multiplexing.
 Multiplexing quickly switches between rows at a high frequency (e.g.,
60 Hz), creating the illusion that all LEDs are lit simultaneously.
3. LED Drivers:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 48
 To control the individual LEDs, driver ICs (such as the MAX7219) are
used. These chips handle the multiplexing and simplify the control of
the matrix.
4. Controlling Pixels:
 By activating a specific row and column, a particular pixel is
illuminated. For instance, to light up the LED at position (1,1), you
activate row 1 and column 1. The same concept applies for creating
characters or images by controlling multiple pixels.

Specifications of 8x8 Dot Matrix Display

Feature Specification
Matrix Size 8x8 (64 LEDs)
Voltage 5V (Typically)
Interface Common interfaces: SPI, I2C
LED Color Typically Red, Green, or RGB
Control IC MAX7219 (for SPI-based control)
Current Consumption ~100mA for full brightness
Dimensions 32mm x 32mm x 6mm (depends on model)

Applications
1. Scrolling Text:
 Display scrolling messages or announcements, typically used in
information boards, digital signage, or home projects.
2. Clocks and Timers:
 Display time and countdown timers on digital clocks or countdown
projects.
3. Games:
 Create simple pixel-based games like Pong or Snake.
4. Simple Graphics:
 Show basic graphics, logos, or symbols using the individual dots in the
matrix.
5. Indicators:
 Use as status indicators for devices or machines (e.g., battery level,
temperature, etc.).

Advantages of 8x8 Dot Matrix Displays

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 49
1. Flexible Display:
 Capable of displaying text, symbols, and basic graphics, offering
flexibility in visual output.
2. Compact Size:
 The 8x8 matrix is relatively small and compact, making it suitable for
embedded systems and small projects.
3. Low Cost:
 Dot matrix displays are inexpensive compared to larger, more complex
displays like OLED or TFT.
4. Low Power Consumption:
 When using multiplexing techniques, the power consumption can be
optimized, especially in low-power devices.

Limitations
1. Low Resolution:
 With only 64 LEDs, the display resolution is low, limiting the complexity
of the content that can be shown.
2. No Color Display:
 Typically limited to a single color (red, green, or RGB), which may not
be suitable for applications requiring full-color images.
3. Limited Control:
 Without the use of multiplexing or driver ICs, controlling the entire
matrix can be complex and may require a lot of wiring and pins.

Interfacing with Arduino (Using MAX7219)


One of the most common ways to control a 8x8 dot matrix is by using a MAX7219
driver IC, which simplifies the control of the LEDs by reducing the number of
connections required. The MAX7219 uses SPI to communicate with the Arduino,
making it easy to control multiple matrices.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 50
Wiring (MAX7219 and 8x8 Dot Matrix)

MAX7219 Pin Arduino Pin Description


VCC 5V Power supply
GND GND Ground
DIN D11 Data In (SPI)
CLK D13 Clock (SPI)
LOAD D10 Load signal (SPI)
V+ 5V Power for the display
V- GND Ground

Applications in Real-Life Projects


1. Message Board:
 Use multiple 8x8 matrices to create a scrolling text display, useful for
public information boards.
2. Digital Clocks:
 Display time using the 8x8 matrix, with each digit represented by a
block of LEDs.
3. Home Automation:
 Use the matrix to show the status of various home automation devices,
like lights, temperature, or system statuses.
4. Games:
 Create basic games like Pong or Snake by controlling the LED matrix
as a pixel grid.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 51
C. LCD (Liquid Crystal Display)
A Liquid Crystal Display (LCD) is a type of flat-panel display technology that uses
liquid crystals to produce visible images. These liquid crystals do not emit light by
themselves but instead manipulate light passing through them to create images.
LCDs are widely used in various electronic devices like calculators, clocks, TVs,
computer monitors, and embedded systems due to their low power consumption,
thin form factor, and versatility.
How It Works
1. Liquid Crystal Layer:
 At the core of an LCD is a layer of liquid crystals, which are molecules
that align differently when an electric current is applied. These
molecules control the passage of light through the display.
2. Backlight:
 LCDs require an external light source (backlight) since the liquid
crystals do not emit light. The backlight is typically provided by LEDs
placed behind or along the edges of the display.
3. Polarizers:
 LCDs use two polarizing filters (one at the front and one at the back) to
control the direction of light passing through the display. The liquid
crystals align themselves to either block or allow light to pass
depending on the applied voltage.
4. Display Segments:
 LCDs can be categorized into segment-based displays (such as 7-
segment displays) or pixel-based displays (like graphical LCDs). In
pixel-based displays, each pixel is controlled independently to display a
wide range of images or text.

Types of LCD Displays


1. Character LCDs:
 These displays are commonly used in simple text-based applications,
showing a limited number of characters in rows and columns (e.g.,
16x2 or 20x4 character displays).
 Typically used for displaying messages, sensor readings, or status
indicators.
2. Graphical LCDs:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 52
 Graphical displays have a matrix of pixels (e.g., 128x64, 240x128) and
can display a wider variety of images, text, and custom graphics.
 Used in devices requiring more complex outputs, like handheld gaming
devices, digital cameras, and advanced embedded systems.

Specifications of Common LCDs


16x2 LCD (Character LCD)

Feature Specification
Display Size 16 characters per line x 2 lines
Resolution 16x2 (32 characters in total)
Interface Parallel (or I²C via adapter)
Operating Voltage 5V
Backlight Color Typically Green or Blue
Dimensions 80mm x 36mm x 12mm
Current Consumption ~20mA (depends on backlight setting)
Control IC HD44780 or compatible

Applications
1. Embedded Systems:
o LCDs are frequently used to display information like sensor readings,
system statuses, and user interfaces in embedded systems.
2. Consumer Electronics:
o Commonly found in household electronics such as microwave ovens,
calculators, alarm clocks, and thermostats.
3. Data Displays:
o Used in applications that require continuous display of data, such as
digital meters, stock tickers, or weather stations.
4. Industrial Equipment:
o LCDs are used in machines, power meters, and other industrial
equipment for displaying operational data, error messages, and system
statuses.

Advantages of LCD Displays


1. Low Power Consumption:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 53
o LCDs consume less power compared to other displays like OLED or
CRT, especially in character displays, where only a small part of the
screen needs to be lit.
2. Thin and Lightweight:
o The flat nature of LCDs makes them ideal for portable and space-
constrained applications.
3. High Visibility:
o LCDs can be easily viewed in bright conditions with a proper backlight,
making them ideal for outdoor and daylight use.
4. Cost-Effective:
o LCD technology is widely used and inexpensive, making it affordable
for a wide range of applications.

Limitations
1. Limited Viewing Angles:
o LCDs generally have a limited viewing angle, and the display may
appear washed out when viewed from extreme angles.
2. Requires Backlight:
o Unlike OLED, which emits light on its own, an LCD requires a backlight,
which increases its power consumption, particularly in large screens.
3. Lower Contrast Ratio:
o LCDs typically have a lower contrast ratio compared to OLEDs,
especially in bright scenes or dark rooms, due to their reliance on
backlighting.
4. Slower Response Time:
o LCDs generally have slower response times than OLED or LED displays,
which may be noticeable in fast-moving visuals.

Interfacing with Arduino


Wiring (16x2 LCD)

LCD Pin Arduino Pin Description


VSS GND Ground
VDD 5V Power supply
Potentiometer (middle
VO Contrast control
pin)

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 54
RS D12 Register select
RW GND Read/Write mode
E D11 Enable
D4 D5 Data pin 4
D5 D4 Data pin 5
D6 D3 Data pin 6
D7 D2 Data pin 7
A (Anode) 5V Backlight (if applicable)
K (Cathode) GND Backlight ground

Applications in Real-Life Projects


1. Digital Thermometer
o Use a temperature sensor (like the DHT11 or LM35) to display
temperature readings on the LCD.
2. Clock:
o Display the current time using a Real-Time Clock (RTC) module
connected to an LCD.
3. Home Automation System
o Show system statuses like light, temperature, humidity, and power
usage on an LCD display in a home automation project.
4. Sensor Display
o Display data from sensors (e.g., humidity, distance, or pressure) in
real-time on an LCD for monitoring.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 55
V. COMMUNICATION MODULES

A. MFRC522 RFID Reader


The MFRC522 is a popular RFID (Radio Frequency Identification) reader and writer
module that operates at a frequency of 13.56 MHz. It is commonly used in
embedded systems to read and write RFID tags, allowing for applications like access
control, inventory management, and contactless payment systems. The MFRC522 is
cost-effective, easily interfaced with microcontrollers (like Arduino), and widely
available in the maker and DIY electronics community.

How It Works
1. Radio Frequency Communication:
o The MFRC522 communicates using RFID technology that operates on
the 13.56 MHz frequency band. RFID tags contain a chip and an
antenna, and when the tag is brought near the RFID reader, it
communicates wirelessly with the reader.
2. Antenna:
o The MFRC522 module uses an antenna to transmit and receive signals.
When an RFID tag comes into range, the antenna generates a
magnetic field that powers the tag and facilitates communication
between the tag and the reader.
3. Modulation:
o The MFRC522 uses Amplitude Shift Keying (ASK) modulation to
communicate with RFID tags. The RFID tag responds by changing the
magnetic field, which is detected by the reader's antenna.
4. Data Transfer:
o The reader sends and receives data in digital form, allowing it to read
unique IDs from RFID tags and, depending on the application, store or
process this data.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 56
5. Communication with Microcontroller:
o The MFRC522 communicates with a microcontroller (such as Arduino)
using SPI (Serial Peripheral Interface). This communication is fast
and efficient, allowing the system to read RFID data and take
corresponding actions quickly.

Specifications of MFRC522 RFID Reader

Feature Specification
Operating Frequency 13.56 MHz
Interface SPI (Standard), I2C (with additional module)
Operating Voltage 3.3V to 5V
Current Consumption 13.5mA (idle), up to 30mA (active)
Range Up to 5 cm (depends on tag and environment)
Protocol ISO/IEC 14443 A/MIFARE
Data Storage Unique ID for each tag
Control IC MFRC522

Applications
1. Access Control Systems:
o RFID is commonly used in access control systems, where RFID tags (in
the form of cards, key fobs, or wristbands) are used to grant access to
secure areas.
2. Inventory Management:
o RFID tags can be placed on items, and the MFRC522 can be used to
track inventory by reading the tags when items are scanned.
3. Cashless Payments:
o RFID readers are used in contactless payment systems, allowing users
to pay by simply tapping their RFID-enabled card or device.
4. Attendance Systems:
o RFID is often used in schools and workplaces for attendance systems
where an RFID tag (student ID or employee card) is scanned to record
presence.
5. Library Systems:
o RFID tags are placed in books, and the MFRC522 is used to track books
during check-out and return.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 57
Advantages of MFRC522 RFID Reader
1. Low Cost:
o The MFRC522 module is inexpensive and widely available, making it
accessible for hobbyists, students, and developers.
2. Ease of Use:
o The MFRC522 is easy to interface with microcontrollers like Arduino,
with available libraries and sample code.
3. Fast Data Transfer:
o The module uses SPI for fast and efficient data transfer, ensuring quick
reading and processing of RFID data.
4. Compact Size:
o The module is small and lightweight, making it suitable for use in
embedded systems and portable applications.
Limitations
Short Range:
 The typical operating range is about 5 cm or less, which limits its use in
applications requiring a longer read distance.
Limited Tag Compatibility:
 The MFRC522 is designed to work with ISO 14443-A RFID tags and certain
MIFARE tags, limiting compatibility with other RFID standards.
Power Consumption:
 Although the MFRC522 is low-power, it still requires a constant power supply
to function and may not be ideal for battery-powered projects unless carefully
managed.

Interfacing with Arduino


The MFRC522 module can easily be interfaced with an Arduino using SPI
communication. The following shows the wiring and a simple example for reading
an RFID tag:
Wiring (MFRC522 to Arduino)

MFRC522 Pin Arduino Pin Description


SDA D10 Select (chip select)
SCK D13 Clock signal
MOSI D11 Master Out Slave In
MISO D12 Master In Slave Out

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 58
IRQ Not connected Interrupt (optional)
GND GND Ground
RST D9 Reset signal
VCC 5V Power supply

Applications in Real-Life Projects


1. Security and Access Control:
o Use the MFRC522 to create a simple door-lock system that only unlocks
when the correct RFID card is scanned.
2. Library Checkout System:
o Develop a library system where RFID tags on books are scanned for
check-in and check-out, logging user information and book status.
3. Personalized User Systems:
o Implement systems where user preferences are stored and retrieved
based on the scanned RFID tag, like smart home settings.
4. Inventory Tracking:
o Use RFID tags for inventory management, allowing a system to
automatically track products by scanning the tags.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 59
B. GSM (Global System for Mobile Communications) Module
The GSM module is a device that allows microcontrollers (like Arduino or Raspberry
Pi) to communicate over a cellular network, enabling them to send and receive SMS
messages, make and receive voice calls, and even connect to the internet using
mobile data. One of the most commonly used GSM modules is the SIM900 or
SIM800, which provides a low-cost way to integrate cellular communication into
various projects.
GSM modules are widely used in projects that require remote communication, such
as home automation systems, vehicle tracking, remote weather stations, and
security systems.

How It Works
1. Communication via Cellular Network:
 The GSM module communicates with a mobile network (cellular tower)
via SIM cards. Once the module is powered and a valid SIM card is
inserted, it can access mobile networks to send SMS messages, make
calls, or access mobile data services.
2. Serial Communication:
 GSM modules typically use serial communication (UART), allowing
them to communicate with microcontrollers. Through this interface,
commands are sent to the GSM module to perform actions like sending
an SMS, receiving messages, or making a call.
3. AT Commands:
 The GSM module uses AT commands (Attention commands) to
interface with the microcontroller. These commands are used to control
the module’s functions, such as sending SMS, checking signal strength,
and dialing a number.
4. Power Requirements:
 GSM modules require a power supply of 3.4V to 4.4V, depending on
the module. A separate power supply is often used to avoid power
fluctuations from the microcontroller.
Specifications of GSM Modules (e.g., SIM900)

Feature Specification
Operating Voltage 3.4V to 4.4V
Communication Interface UART (Serial), sometimes USB or SPI
Frequency Band 850 MHz, 900 MHz, 1800 MHz, 1900 MHz (Quad-band)
Data Communication GPRS (General Packet Radio Service)

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 60
SMS Send and receive SMS (Text messages)
Call Functionality Make and receive voice calls
Power Consumption ~60-250mA (depends on activity, e.g., sending SMS)
Standby Current ~1-2mA
Control Interface AT Commands (via Serial Communication)
Size ~30mm x 25mm

Applications
1. Remote Communication:
o SMS Alerts: The GSM module is used in systems like alarm systems
to send SMS alerts when triggered. It can also be used in weather
stations to send periodic updates.
2. Home Automation:
o GSM is commonly integrated into home automation systems, allowing
users to control home appliances via SMS. For example, turning on/off
lights, fans, or gates remotely using SMS commands.
3. Vehicle Tracking Systems:
o GSM modules are used in GPS tracking systems for vehicles. The GSM
module sends real-time location data via SMS or GPRS to a central
server or a mobile phone.

4. Security Systems:
o GSM modules are used in security systems where, in case of
intrusion, the system sends an SMS alert or makes a phone call to a
predefined number to notify the user.
5. Health Monitoring:
o In remote health monitoring systems, the GSM module sends
patient data (like heart rate, temperature) via SMS to healthcare
providers for quick monitoring and action.

Advantages of GSM Modules


1. Global Connectivity:
o GSM is widely available across the world, making it a reliable choice for
global communication projects, especially in remote or rural areas
where Wi-Fi may not be available.
2. Cost-Effective:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 61
o GSM modules are generally inexpensive, and using a simple prepaid
SIM card in a GSM module makes it a low-cost communication
solution.
3. Wide Range of Applications:
o The ability to send SMS, make calls, and even use mobile data enables
a wide variety of uses, from simple alerts to complex remote
communication systems.
4. No Need for Wi-Fi or Internet:
o Unlike Wi-Fi-based communication systems, GSM does not require an
internet connection, making it highly suitable for areas with poor or no
internet coverage.

Limitations of GSM Modules


1. Coverage Dependence:
o GSM modules depend on cellular network coverage, so if there is no
signal or the network is down, communication will fail.
2. Slow Data Transfer:
o The data transfer rate for GSM (especially GPRS) is relatively slow
compared to other technologies like Wi-Fi or LTE.

3. Power Consumption:
o GSM modules can be power-hungry, especially during active
communication (e.g., sending SMS or making calls), which may not be
ideal for battery-powered devices unless managed efficiently.
4. SIM Card Management:
o GSM modules require a SIM card, which introduces additional costs,
and some modules might have restrictions on the types of SIM cards
they can work with.

Interfacing with Arduino


The GSM module can be interfaced with an Arduino using Serial Communication
(UART). Here’s how to connect and use the GSM module to send an SMS:
Wiring (GSM Module to Arduino)

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 62
GSM Module Pin Arduino Pin Description
VCC 5V Power supply for the GSM module
GND GND Ground
TXD RX (D2) Transmit data from GSM to Arduino
RXD TX (D3) Receive data from Arduino to GSM
RST Not connected Reset pin (optional)

Applications in Real-Life Projects


1. Security System:
o GSM can be used in a home security system to send SMS alerts in case
of intrusion, motion detection, or fire alarm activation.
2. Weather Monitoring:
o A GSM module in a weather station can send SMS alerts when the
temperature, humidity, or other parameters reach critical levels.
3. Automated Alerts:
o Use GSM to create an automated alert system for medical, industrial,
or agricultural purposes. For example, an SMS notification when a
machine fails or when crops require attention.
4. Remote Control:
o Implement remote control of devices by sending SMS commands. For
instance, control home appliances or industrial equipment using SMS.

Diagram

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 63
C. Keypad Module
The keypad module is a commonly used input device that allows users to provide
numerical or textual input to an embedded system. It typically consists of an array
of buttons arranged in rows and columns, with each button representing a unique
key press. The most common keypad configurations are 3x4 (3 rows and 4 columns)
and 4x4 (4 rows and 4 columns), but they can vary based on the design.
Keypads are used in various applications, including security systems, calculators,
and any project requiring user input, such as PIN entry systems or menu navigation
interfaces.
How It Works
1. Matrix Configuration:
o The keypad operates as a matrix where each key is located at the
intersection of a row and a column. When a key is pressed, it connects
one specific row and one column, creating a unique combination that
can be detected by the microcontroller.
2. Row and Column Scanning:
o A typical keypad has multiple rows and columns. The microcontroller
scans the rows and columns to detect which key is pressed.
 Each row is set as an output pin, and each column is set as an
input pin.
 The microcontroller sends a signal through each row, one by
one, and checks the state of the columns to identify the pressed
key.
3. Keypad Encoding:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 64
o Each key press generates a unique combination of row and column
signals, which is then converted into a corresponding value (like a
number or character).
o For example, in a 4x4 keypad, pressing the first key in the first row
and first column (key "1") will produce a specific signal corresponding
to that key.
4. Connection to Microcontroller:
o The keypad is usually connected to a microcontroller through digital I/O
pins, where the microcontroller continuously checks the state of each
key, scanning the rows and columns to detect key presses.

Specifications of Keypad Modules

Feature Specification
Number of Keys 3x4 (12 keys), 4x4 (16 keys)
Connection Interface Digital I/O pins (for row and column scanning)
Operating Voltage 3.3V to 5V
Current Consumption Low current consumption
Keypad Type Membrane or mechanical switch-based
Keypad Material Typically rubber or conductive membrane
Size Varies, typically around 5x5 cm for 4x4

Applications
1. Access Control Systems:
o Keypads are widely used in security systems where users need to enter
a PIN code to gain access to restricted areas or devices.
2. ATM Machines:
o ATM machines use keypads for users to enter their PIN codes and
perform banking transactions.
3. Home Automation Systems:
o In home automation, keypads are used to control devices such as
lights, fans, and alarms, based on user input.
4. Electronic Locking Systems:
o A keypad is often used to input a password to unlock a door or safe.

5. Calculator or Input Devices:


o Keypads can be used in devices requiring numerical input, such as
calculators or measurement devices.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 65
6. Industrial Control Systems:
o Keypads are used in industrial machinery for inputting values like
parameters or settings.

Advantages of Keypad Modules


1. Compact Design:
o Keypads are compact and take up minimal space, making them ideal
for applications where space is a concern.
2. Low Power Consumption:
o Keypad modules typically consume very little power, making them
suitable for battery-powered applications.
3. Easy Integration:
o The keypad can be easily integrated into microcontroller-based
projects (like Arduino or Raspberry Pi) due to the simple digital
interface.
4. Durability:
o Membrane keypads are durable and can withstand frequent use,
especially in industrial and security applications.
5. Versatility:
o Keypads can be used in a wide range of projects, including security,
automation, and user interface systems.

Limitations of Keypad Modules


1. Limited Input:
o While keypads are useful for simple input, they are not ideal for more
complex input systems, such as typing long text or entering detailed
information.
2. No Feedback:
o Keypads typically don't provide feedback to the user (e.g., visual or
auditory), so additional components like LEDs or displays are often
needed.
3. Wear and Tear:
o Mechanical keypads may wear out over time, especially if they are
frequently pressed, leading to reduced reliability.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 66
Interfacing with Arduino
Keypad modules are typically interfaced with microcontrollers using digital I/O
pins for row and column scanning. For a 4x4 keypad, 8 pins (4 for rows and 4 for
columns) are required. There are also libraries available for Arduino (like Keypad
library) to simplify the process of detecting key presses.

Diagram

D. GPS (GLOBAL POSITIONING SYSTEM) MODULE


The GPS module is a device that receives signals from satellites in Earth's orbit
and calculates its position (latitude, longitude, altitude) and time. GPS modules are
widely used in navigation systems, location tracking, and various outdoor
applications. They typically include an integrated receiver capable of detecting
signals from the GPS satellite network.
GPS modules are used in a wide variety of applications, from personal navigation
(in vehicles or on foot) to more complex use cases like tracking (e.g., vehicle
tracking, drone navigation) and geographic information systems (GIS).
How It Works
1. Satellite Communication:
o The GPS module communicates with multiple GPS satellites, each
broadcasting its position and time. By receiving signals from at least 4
satellites, the GPS module can triangulate its position.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 67
2. Triangulation Process:
o The GPS module uses the principle of triangulation to calculate the
position. Each satellite sends a signal that includes the satellite’s
position and the exact time the signal was sent.
o The module calculates the time it took for the signal to reach the
receiver and multiplies it by the speed of light to determine the
distance to each satellite.
o Using the distances from multiple satellites, the GPS module can
calculate its latitude, longitude, and altitude.
3. NMEA Data Format:
o GPS modules typically output data in the NMEA (National Marine
Electronics Association) format. The NMEA format provides location
data, including latitude, longitude, altitude, time, and other relevant
information.
4. Accuracy:
o The accuracy of GPS modules depends on various factors such as
signal strength, satellite coverage, and the environment (e.g., urban
areas with tall buildings may cause signal interference). Typically, GPS
can provide accuracy within 5-10 meters under good conditions, but
more advanced systems (like differential GPS) can achieve sub-meter
accuracy.

Specifications of GPS Modules

Feature Specification
Operating Voltage 3.3V to 5V
Communication Interface UART (Serial), I2C, or SPI
Signal Acquisition Time Typically 30-60 seconds (Cold Start)
Accuracy 5-10 meters (under ideal conditions)
1 Hz (1 update per second) or higher in some
Update Rate
models
Antenna Built-in or external antenna
Satellite Channels 20-60 channels (depends on the model)
Size Varies; typically around 3-5 cm for small modules
Power Consumption ~20mA to 50mA depending on activity

Applications
1. Navigation Systems:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 68
o GPS modules are extensively used in automotive navigation systems,
portable GPS devices, and smartphone navigation apps to provide
real-time directions and route planning.
2. Location Tracking:
o Used in vehicle tracking, asset tracking, and personal tracking.
GPS data can be sent over the internet to track locations in real-time.
3. Geotagging:
o GPS modules are used in cameras and smartphones for geotagging,
which involves embedding location data into photos and videos.
4. Surveying and Mapping:
o GPS is an essential tool for creating maps, conducting land surveys,
and generating GIS data.
5. Drones:
o Drones use GPS modules for autonomous navigation, waypoints,
and geo-fencing (limiting the drone's flight area).
6. Agricultural Applications:
o GPS is used in precision farming, enabling automatic control of
tractors, harvesters, and other farming equipment based on location
data.
7. Emergency Services:
o GPS is used in emergency location tracking systems to assist with
rescue operations, ensuring fast response times.

Advantages of GPS Modules


1. Global Coverage:
o GPS works anywhere in the world, as long as there is a clear line of
sight to the sky. There is no dependency on local networks, Wi-Fi, or
cellular coverage.
2. High Precision:
o GPS modules provide accurate positioning, typically within 5 to 10
meters, and are essential for many outdoor navigation applications.
3. Low Power Consumption:
o GPS modules are designed to operate on low power, making them
suitable for battery-operated devices and remote sensing systems.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 69
4. Easy Integration:
o GPS modules are easy to integrate with microcontrollers and other
embedded systems via UART, I2C, or SPI, and are supported by a
variety of libraries in platforms like Arduino and Raspberry Pi.

Limitations of GPS Modules


1. Signal Blockage:
o GPS signals can be blocked or degraded by physical obstacles such as
tall buildings, mountains, dense forests, or indoor environments. This is
known as GPS signal attenuation.
2. Dependence on Clear Skies:
o GPS modules require an unobstructed view of the sky to receive signals
from satellites. In environments with poor visibility, like underground or
inside buildings, GPS performance is severely degraded.
3. Time to First Fix:
o When the GPS module is first powered on or loses its signal (e.g., after
a restart), it can take longer to acquire a position fix. This is known as
cold start (can take from 30 seconds to several minutes). Once it
acquires a fix, the GPS module can provide position updates more
quickly (warm start or hot start).
4. Accuracy Variations:
o In urban environments or areas with signal interference, GPS accuracy
can degrade due to multipath effects (signal reflections off buildings)
and poor satellite geometry.

Interfacing with Arduino


A GPS module can be easily interfaced with an Arduino using serial
communication (UART). Here's how it generally works:
Wiring (GPS Module to Arduino)

GPS Module Pin Arduino Pin Description


VCC 5V or 3.3V Power supply for the GPS module
GND GND Ground
TXD RX (D4) GPS transmit pin to Arduino receive pin
RXD TX (D3) GPS receive pin from Arduino transmit pin

NMEA Data Parsing

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 70
 The data sent from the GPS module is in NMEA format. To parse and display
the GPS data (latitude, longitude, altitude, speed), you can use libraries like
TinyGPS++ or Adafruit GPS in Arduino.
Applications in Real-Life Projects
Automotive Navigation:
 Used in car GPS systems to provide turn-by-turn directions and real-time
tracking of the vehicle’s location.
Personal GPS Tracking:
 Used in wearable devices to track the location of individuals, such as
children or pets, for safety purposes.
Drone Navigation:
 Drones use GPS for autonomous navigation, creating flight paths, and
returning to home locations.
Remote Sensing Systems:
 GPS is used in remote sensing systems for geographical data collection, such
as weather stations, environmental monitoring, and wildlife tracking.

Diagram

VI. ACTUATORS/ OP DEVICES

A. Buzzer Module

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 71
A buzzer is an audio signaling device that produces sound in response to electrical
input. It is commonly used in electronic projects to provide feedback, alerts, or
notifications. Buzzers are available in two types: active buzzers and passive
buzzers, each having distinct characteristics.
Types of Buzzers
1. Active Buzzer:
o An active buzzer has a built-in oscillator circuit, which allows it to
produce sound as soon as power is applied. It requires only a DC
voltage to operate and can generate a sound without requiring an
external signal. It often emits a continuous tone when powered.
2. Passive Buzzer:
o A passive buzzer requires an external signal (such as a square wave)
to generate sound. It does not have a built-in oscillator. By varying the
frequency of the signal, a passive buzzer can produce different tones,
making it more flexible in producing various sounds.

How It Works
1. Active Buzzer:
o When a voltage is applied to an active buzzer, it internally generates a
sound, typically a beep or tone, without requiring a waveform input. It
operates at a fixed frequency (usually between 2kHz to 5kHz) and has
a straightforward on/off operation.
2. Passive Buzzer:
o A passive buzzer works by converting an alternating signal (usually
from a microcontroller or external oscillator) into sound. When a square
wave signal is sent to the buzzer, it vibrates at the frequency of the
wave, producing sound at the corresponding pitch.
3. Frequency Control (for Passive Buzzers):
o A passive buzzer can produce different tones by adjusting the
frequency of the driving signal. For instance, a higher frequency will
generate a higher-pitched sound, while a lower frequency will produce
a deeper sound. This can be useful for generating melodies or alerts
with varying tones.

Specifications of Buzzer Modules

Feature Specification
Type Active or Passive

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 72
Operating Voltage 3V to 5V (typical)
Frequency Range (Active) Fixed frequency (usually 2-5 kHz)
Frequency Range (Passive) Can vary based on the input signal
~10-30 mA for active, ~20-40 mA for
Current Consumption
passive
Sound Level 60-100 dB depending on size and type
Typically, between 10mm and 30mm
Size
diameter
Connection Usually connected through GPIO pins
Response Time Instantaneous (depends on type)

Applications
1. Alarms and Alerts:
o Buzzers are often used in security systems, fire alarms, and smoke
detectors to provide an auditory warning. They are also used in
systems to alert users of specific conditions, such as low battery or
errors.
2. Timers and Clocks:
o In applications such as kitchen timers or alarm clocks, buzzers are
used to indicate the completion of a countdown or as an alarm to wake
up the user.
3. Interactive Systems
o Buzzers are commonly used in keypad systems, quiz boards, and
game shows to provide audio feedback when a correct or incorrect
answer is given.
4. Control Feedback
o In embedded systems, buzzers are used to provide simple feedback
to users, indicating a button press or confirming an action, such as a
successful task completion.
5. Automated Systems
o Buzzers are used in robots and automated machines to indicate
successful operation, warning conditions, or user interaction.

Advantages of Buzzer Modules


1. Simple Operation:
o Buzzers are easy to integrate into projects and typically require
minimal control signals, especially active buzzers, which only need
power to function.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 73
2. Low Power Consumption
o Buzzers, especially active ones, consume very little power, making
them ideal for battery-operated devices.
3. Cost-Effective
o Buzzers are relatively inexpensive components, making them ideal for
a wide variety of applications.
4. Audible Feedback
o Buzzers provide clear, audible feedback that can be heard in noisy
environments, making them suitable for alarms or notifications.

Limitations of Buzzer Modules


1. Limited Sound Quality
o Buzzers typically produce simple tones or beeps. While this is sufficient
for alerts or notifications, they are not suitable for high-quality sound
or music.
2. Audible Range
o The sound from a buzzer may not carry well over long distances,
especially in environments with a lot of ambient noise or for low-power
buzzers.
3. Lack of Tone Variety (Active Buzzers)
o Active buzzers usually emit a fixed tone and cannot produce a wide
range of sounds. For more complex audio outputs, a passive buzzer
or other audio devices are required.

Interfacing with Arduino


Wiring the Buzzer to Arduino
 Active Buzzer
o Connect one pin of the active buzzer to a digital output pin on the
Arduino (e.g., Pin 9).
o Connect the other pin of the buzzer to GND (Ground).

 Passive Buzzer
o Connect one pin of the passive buzzer to a PWM-capable digital output
pin (e.g., Pin 3) on the Arduino.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 74
o Connect the other pin of the buzzer to GND.

Controlling the Buzzer


 Active Buzzer: To turn on the buzzer, set the corresponding Arduino pin to
HIGH. To turn it off, set the pin to LOW.
 Passive Buzzer: To control the tone, use tone() and noTone() functions in
Arduino for generating a specific frequency. For example, tone(9, 1000); will
play a 1kHz tone on pin 9.

Diagram

B. Servo Motor Module


A servo motor is a type of motor that is used for precise control of angular
position, velocity, and acceleration. Unlike a standard DC motor, a servo motor is
designed for precise movement, typically controlled by sending a specific pulse
signal. Servo motors are widely used in applications such as robotics, automation,
remote-controlled vehicles, and mechanical systems that require exact positioning
How It Works
1. Motor Structure:
 A typical servo motor consists of a DC motor, a gear mechanism, a
control circuit, and a feedback system. The DC motor provides
rotational movement, while the gear mechanism adjusts the speed and
torque. The feedback system (usually an encoder or potentiometer)
helps the motor maintain the desired position.
2. Control Signal (PWM):
 The servo motor is typically controlled by a Pulse Width Modulation
(PWM) signal. The PWM signal varies the duty cycle (the length of
time the signal is high in each cycle), which determines the position of
the motor’s shaft.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 75
 The typical range of PWM control is from 0 to 180 degrees for most
servos, though some high-torque or continuous rotation servos may
have different ranges.
 A 1ms pulse typically corresponds to a 0° position, while a 2ms pulse
corresponds to 180°.
3. Position Control:
 The servo motor adjusts its shaft position based on the received PWM
signal. The motor will continuously correct itself until it reaches the
target position as determined by the PWM signal. This feedback loop
allows for accurate and stable positioning.
4. Torque and Speed:
 Servo motors offer high torque at low speeds and can hold a position
under load. However, the torque decreases as the speed increases.
They are typically used for applications requiring accurate control over
a small range of motion rather than continuous rotation.

Types of Servo Motors


1. Standard Servo Motors:
 These are the most common type, and they provide precise angular
control. They typically have a limited rotation range (usually 0° to
180°), making them ideal for tasks like positioning robotic arms or
controlling the rudder of an RC plane.
2. Continuous Rotation Servo Motors:
 These motors allow for continuous rotation in either direction. By
adjusting the pulse width, you can control the speed and direction of
the motor. These servos are often used in applications like driving
robots or moving wheels.
3. High-Torque Servo Motors:
 High-torque servos are designed for applications that require higher
strength to turn a load. These are often used in robotics or automation
where a larger amount of force is required.
4. Digital vs. Analog Servos:
 Digital Servos provide faster response times and more precise control
compared to analog servos, as they use microcontrollers to provide
feedback. Digital servos are generally more expensive but offer better
performance for high-precision tasks.

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 76
Specifications of Servo Motors

Feature Specification
Voltage 4.8V to 6V (commonly)
Torque Varies (usually 1-20 kg·cm for standard servos)
Speed Varies (typically 0.1-0.2 sec/60°)
Control Signal Pulse Width Modulation (PWM)
Range of Motion 0° to 180° (standard servos)
Current Consumption ~100-500mA (depends on load and torque)
Size Typically ranges from 20mm to 50mm in diameter
Type Standard, Continuous, High-Torque

Applications
1. Robotics:
 Servo motors are commonly used in robotics for controlling the
movement of arms, grippers, and legs. They allow for precise control of
angles, making them ideal for robotic systems requiring high precision.
2. Remote-Controlled Vehicles:
 In RC planes, helicopters, cars, and boats, servos control the
movement of control surfaces like rudders, ailerons, and elevators.
They are also used for steering and throttle control.
3. Camera Gimbals:
 Servo motors are used in camera stabilizers (gimbals) to provide
precise adjustments to the camera's position, ensuring smooth footage
by compensating for camera shake.
4. Automation Systems:
 Servo motors are used in CNC machines, conveyor belts, and
automated assembly lines where precise control of movement is
necessary.
5. Mechanical Systems:
 Servo motors are used to control various mechanical parts, such as
adjusting valves in fluid control systems or positioning solar panels for
maximum efficiency.

Advantages of Servo Motors


1. Precision and Accuracy:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 77
 Servo motors are highly accurate, with feedback mechanisms ensuring
they can maintain a precise position and move exactly where they are
commanded to.
2. High Torque at Low Speeds:
 Servo motors provide high torque at low speeds, making them suitable
for applications where strong force is required to position a load.
3. Compact and Lightweight:
 Servo motors are typically small and lightweight, making them ideal for
applications where size and weight are critical factors.
4. Feedback Mechanism:
 Servo motors come with built-in feedback, which ensures that the
motor can self-correct to achieve the desired position, making them
highly reliable for positioning applications.

Limitations of Servo Motors


1. Limited Range of Motion:
 Most standard servo motors have a limited range of motion (0° to
180°), so they cannot rotate continuously. For continuous rotation,
specialized servo motors are needed.
2. Torque Limitation:
 While servos are known for providing high torque at low speeds, their
torque decreases significantly with speed. They are not suitable for
applications that require continuous high-torque rotation.
3. Power Consumption:
 Servo motors consume more power compared to simple DC motors,
especially under load. This may be a consideration in battery-powered
applications.
4. Cost:
 High-performance servo motors, especially digital or high-torque
models, can be more expensive than basic motors.

Interfacing with Arduino


Wiring the Servo to Arduino

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 78
Servo Motor Pin Arduino Pin Description
VCC 5V Power supply for the servo motor
GND GND Ground
Signal (PWM) Digital Pin PWM signal to control position

Diagram

C. Stepper Motor
A stepper motor is a type of DC motor that moves in discrete steps, with each
step representing a fixed angle of rotation. Unlike standard DC motors, which rotate
continuously when powered, stepper motors offer precise control over position
without the need for feedback systems. This makes them ideal for applications
requiring accurate and repeatable motion, such as in robotics, 3D printers, and CNC
machines.
How It Works
1. Step Angle:
o A stepper motor moves in defined increments, or steps, typically
ranging from 0.9° to 1.8° per step. The exact angle per step depends
on the design of the motor. For example, a 1.8° stepper motor will
make 200 steps to complete one full rotation (360° ÷ 1.8° = 200
steps).
2. Electromagnetic Coils:
o Stepper motors are driven by electromagnetic coils that are
energized in a specific sequence. These coils are arranged around a
central rotor, and when energized, they create magnetic fields that
attract or repel the rotor, causing it to step forward or backward.
3. Modes of Operation:
o Full-Step: In full-step mode, two coils are energized at a time, and the
motor steps in full increments (e.g., 1.8° per step).

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 79
o Half-Step: In half-step mode, the current is applied in a way that the
motor takes half the number of steps per full rotation, increasing
resolution and smoothness.
o Microstepping: Microstepping divides each step into smaller
increments (e.g., 0.1°), allowing for even smoother movement and
finer control.
4. Control Signal (Pulse Input):
o Stepper motors are controlled by pulses sent to the motor driver. Each
pulse corresponds to one step, and by sending a series of pulses, the
motor rotates a specific number of steps. The speed and direction of
rotation are determined by the frequency and sequence of the pulses.

Types of Stepper Motors


1. Permanent Magnet Stepper Motors (PM)
o These motors use permanent magnets in the rotor. They are
typically used in low-torque applications, offering good performance at
low speeds.
2. Variable Reluctance Stepper Motors (VR)
o These motors use a rotor made of soft iron, with no permanent
magnets. They are simpler in construction and are often used in high-
speed applications but have lower torque at low speeds.
3. Hybrid Stepper Motors
o These motors combine the features of both permanent magnet and
variable reluctance types, offering a good balance of torque and
performance. They are the most common type used in practical
applications due to their high torque and accuracy.

Specifications of Stepper Motors

Feature Specification
Voltage 3.6V to 12V (commonly)
Step Angle 0.9°, 1.8°, or fractional (microstepping)
Current per Phase 1A to 2A (depends on the motor)
Typically 10 to 100 N·cm (depends on
Holding Torque
motor)
Speed Range Varies based on motor and driver
Shaft Diameter Typically 5mm to 8mm
Weight 100g to 500g (depends on size and

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 80
torque)
Requires a stepper motor driver for
Driver Requirement
operation

Applications
1. 3D Printers:
o Stepper motors are widely used in 3D printers to control the
movement of the extruder and print bed. The precise control over step
angles ensures accurate positioning of the printhead.
2. CNC Machines:
o Stepper motors are used in CNC machines (computer numerical
control) for controlling the position of the cutting tool, enabling highly
accurate cutting, engraving, and milling operations.
3. Robotics:
o In robotic systems, stepper motors are used to control limbs,
grippers, and wheels, providing precise movements in joint actuators
and steering systems.
4. Camera Gimbals:
o Stepper motors are used in camera gimbals to stabilize and adjust
the orientation of the camera, providing smooth and precise control
over positioning.
5. Automated Systems:
o Stepper motors are used in automated machines for tasks such as
material handling, conveyor belts, and process control systems where
precise rotation and positioning are required.
6. Medical Equipment:
o Stepper motors are used in medical devices like infusion pumps,
surgical robots, and prosthetic devices where accurate movement is
critical.

Advantages of Stepper Motors


1. Precise Control:
o Stepper motors provide precise, incremental movement, making
them ideal for applications that require accurate positioning, such as
robotics and CNC machines.
2. Open-Loop Control:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 81
o Stepper motors can be operated in an open-loop system, meaning
they do not require feedback sensors to know their position. This
simplifies the control circuitry and reduces costs.
3. High Torque at Low Speeds:
o Stepper motors provide high torque even at low speeds, making them
ideal for applications where slow and steady movement is needed.
4. Reliability:
o Stepper motors are simple in construction and have no brushes or
commutators, making them durable and requiring minimal
maintenance.

Limitations of Stepper Motors


1. Efficiency:
o Stepper motors tend to be less efficient compared to other motors
(e.g., DC motors) because they consume more power to hold a
position, even when stationary.
2. Torque Decreases with Speed:
o The torque of a stepper motor typically decreases at higher speeds,
limiting its use in applications requiring both high speed and high
torque.
3. Complexity with Higher Speeds:
o Stepper motors can experience loss of steps or stalling at higher
speeds or under heavy load, requiring careful control to prevent
skipping or misalignment.
4. Heat Generation:
o Stepper motors can generate significant heat during operation,
especially under heavy loads or when driven continuously, requiring
adequate cooling or thermal management.

Interfacing with Arduino


Wiring the Stepper Motor to Arduino
To control a stepper motor, you typically need a stepper motor driver (e.g.,
A4988, ULN2003) between the motor and the Arduino to handle the higher
currents required by the motor.
 Stepper Motor:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 82
o Connect the motor's coil wires (typically four wires for bipolar motors)
to the motor driver.
 Arduino to Motor Driver:
o Connect the control pins (step, direction, enable) of the motor driver
to the digital pins on the Arduino (e.g., pins 2, 3, and 4).
 Power:
o Connect the motor power supply to the motor driver, ensuring it
matches the motor's rated voltage (often 5V to 12V).
o The Arduino and motor driver share a common ground (GND).

Diagram

D. RELAY
A relay is an electromechanical switch used to control a high-voltage or high-
current circuit with a low-voltage control signal. It consists of a coil, an armature (a
moving part), and one or more sets of contacts. When the coil is energized, it
creates a magnetic field that pulls the armature, which in turn closes or opens the
contacts. Relays are used to isolate low-voltage circuits from high-voltage circuits
and are commonly found in automotive, home automation, and industrial
applications.
How It Works
1. Electromagnetic Coil:
o The relay contains a coil of wire that, when energized, generates a
magnetic field. The coil is typically powered by a low-voltage signal
(such as from a microcontroller or an external circuit).

2. Armature and Contacts:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 83
o Attached to the coil is an armature, a moving metal piece that is
attracted to the magnetic field created when the coil is energized. The
armature is connected to a set of contacts that open or close based
on the movement of the armature.
3. Switching Mechanism:
o Normally Open (NO) Contacts: When the relay coil is not energized,
the contacts remain open. When the coil is energized, the armature
pulls the NO contacts together, closing the circuit and allowing current
to flow.
o Normally Closed (NC) Contacts: When the relay is not energized,
the contacts are closed. Energizing the coil pulls the armature, opening
the NC contacts and breaking the circuit.
4. Types of Relays:
o SPST (Single Pole Single Throw): This is the simplest type, with a
single contact that opens or closes the circuit.
o SPDT (Single Pole Double Throw): A more complex relay with one
input (common) and two outputs (NO and NC). It can switch between
two circuits, allowing the output to change between two different
states.
o DPDT (Double Pole Double Throw): A relay with two independent
switches, each with NO and NC contacts, allowing it to control two
separate circuits simultaneously.

Relay Specifications

Feature Specification
Coil Voltage 5V, 12V, 24V, or other standard values
Contact Voltage Typically 110V AC or 240V AC
Current Rating 10A to 30A (depends on relay model)
Coil Resistance 50Ω to several kΩ (depends on the relay)
Contact Configuration NO, NC, SPST, SPDT, DPDT
Switching Speed Typically 10 to 20 milliseconds
Mechanical Life 10 million operations (depends on model)
Electrical Life 100,000 to 1 million operations
Operating Temperature -40°C to 85°C (depending on the relay model)

Applications
1. Home Automation:
o Relays are widely used in home automation systems to control lights,
fans, or other appliances using microcontrollers (like Arduino or

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 84
Raspberry Pi). They allow you to control high-power devices with low-
power signals.
2. Automotive:
o Relays are found in car electrical systems, such as for controlling
headlights, horns, air conditioning systems, and other high-current
components. A low-current control circuit is used to switch the relay,
which then activates a high-current circuit.
3. Industrial Control:
o Relays are essential in industrial control systems for switching large
machines, motors, or actuators. They help isolate the control circuit
from high-power components, improving safety and reliability.
4. Safety Systems:
o Relays are used in safety-critical applications where they control circuit
breakers, emergency shutdown systems, and alarms. Their ability to
provide electrical isolation between control and power circuits is vital
for ensuring safe operation.
5. Telecommunication Systems:
o In telecommunications, relays are used to route signals between
different parts of a network. They provide a way to switch circuits on
and off or select between different paths.

Advantages of Relays
1. Electrical Isolation:
o One of the key advantages of a relay is electrical isolation between
the control and switching circuits. This ensures that high-voltage
components do not interfere with low-voltage control signals,
protecting sensitive components.
2. High Power Switching:
o Relays can control high-power circuits (up to 30A or more) using low-
power control signals, making them ideal for switching devices like
motors, heaters, and lights.
3. Versatile Switching:
o Relays are available with various contact configurations (NO, NC, SPDT,
DPDT), allowing them to be used in a wide range of applications, from
simple on/off switching to more complex tasks.
4. No Need for Complex Circuitry:

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 85
o A relay can be used to control high-power circuits without the need for
complex circuitry, making them a simple and cost-effective solution for
switching.

Limitations of Relays
1. Slower Switching Speed:
o Compared to solid-state switches (like transistors or MOSFETs), relays
are slower and may not be suitable for high-speed switching
applications.
2. Mechanical Wear:
o Mechanical relays have moving parts, which can wear out over time
and limit the number of operations. This makes them less ideal for
high-frequency switching.
3. Noise and Sparking:
o When the contacts open or close, especially under high current, they
can produce sparking or electrical noise, which can lead to
component degradation and interference in sensitive circuits.
4. Power Consumption:
o The coil in a relay consumes power while energized. While it is
generally low (in the range of a few milliwatts to a few watts), it still
requires constant energy when the relay is in operation.

Interfacing with Arduino


Wiring the Relay to Arduino
To control a relay with an Arduino, you need a relay module (which includes a
driver circuit) to handle the higher current needed by the relay coil.

Component Connection to Arduino Description


Relay Module VCC -> 5V (Arduino) Power supply for the relay module
Relay Module GND -> GND (Arduino) Ground connection
Relay Module IN -> Digital Pin (e.g., Pin 7) Control pin for activating the relay
Relay Contacts Connect to the high-power circuit Controls the high-power device (e.g., a motor or
lamp)

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 86
Diagram

REFERENCES USED IN THIS ASSIGNMENT


HowToMechatronics. (n.d.). DHT11/DHT22 sensors - Temperature and humidity tutorial
using Arduino https://howtomechatronics.com/tutorials/arduino/dht11-dht22-sensors-temperature-
and-humidity-tutorial/

PlayWithCircuit. (n.d.). How to interface DHT11 and DHT22 sensors with Arduino Uno
https://playwithcircuit.com/how-to-interface-dht11-and-dht22-sensors-with-arduino-uno/

SparkFun Electronics. (n.d.). DHT22 datasheet


https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 87
Utmel. (n.d.). DHT11 vs. DHT22: Datasheet, pinout, and features
https://www.utmel.com/components/dht11-vs-dht22-datasheet-pinout-and-features?id=1148

Components101. (n.d.). DS18B20 temperature sensor


https://components101.com/sensors/ds18b20-temperature-sensor

Electroduino. (n.d.). DS18B20 waterproof temperature sensor


https://www.electroduino.com/ds18b20-waterproof-temperature-sensor/

Random Nerd Tutorials. (n.d.). Arduino K-type thermocouple with MAX6675


https://randomnerdtutorials.com/arduino-k-type-thermocouple-max6675/

Bosch Sensortec. (n.d.). BME280 datasheet https://www.mouser.com/datasheet/2/783/BST-


BME280-DS002-1509607.pdf

Random Nerd Tutorials. (n.d.). Arduino BMP388 barometric pressure sensor


https://randomnerdtutorials.com/arduino-bmp388/

Robocraze. (n.d.). MQ series gas sensor https://robocraze.com/blogs/post/mq-series-gas-sensor

Little, J. (n.d.). Arduino lesson: Soil moisture sensor [PDF file]


http://johnlittle.pbworks.com/w/file/fetch/145397499/Arduino%20lesson%20-%20soil%20moisture
%20sensor.pdf

TME. (n.d.). Papirs datasheet


https://www.tme.eu/Document/52c180ac33c503d43640c8b77161fa7d/bltn_eng_papirs.pdf

Analog Devices. (n.d.). DS3231 datasheet https://www.analog.com/media/en/technical-


documentation/data-sheets/DS3231.pdf

Ariat Tech. (n.d.). Working principle and application of HX711 load cell amplifier
https://www.ariat-tech.com/blog/working-principle-and-application-of-hx711-load-cell-amplifier.html

SparkFun Electronics. (n.d.). HX711 datasheet


https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf

DIGITAL LOGIC AND MICRO CONTROLLER | GROUP NO. 7 ASSIGNMENT | NTA LEVEL 7 – 1 2024 88

You might also like