Introduction to microcontroller
Define microcontroller
Microcontroller is a complete microprocessor system built
on a single integrated circuit.
OR compact integrated circuit designed to perform
specific tasks.
Reason of building microcontroller
Microcontroller reduces the cost of building simple
products using microprocessor by setting up all the
systems on a single integrated chip
Integrated chip or microcontroller consist of
CPU,RAM,ROM,I/Oport,timers,clock
SINGLE CHIP 4 BIT MICROCONTROLLER
8 bit microcontroller
Application of microcontroller
🔌 Home Appliances
Microcontrollers are embedded in many everyday devices to
handle control logic and interface with sensors and actuators:
Microwave ovens – control cooking time, keypad input,
and display
Washing machines – manage cycles, water level, motor
control
Air conditioners – regulate temperature, compressor,
fan speed
Refrigerators – monitor temperature, defrost cycles,
door sensors
TVs & remote controls – decode user inputs and control
settings
🚗 Automobiles
Automotive systems use microcontrollers for safety, control,
and comfort:
Engine control units (ECUs) – manage fuel injection,
ignition timing
Anti-lock braking systems (ABS)
Airbag deployment systems
Power windows and locks
Dashboard instrument clusters
Climate control and infotainment
🏥 Medical Devices
Microcontrollers are vital in many modern health-monitoring
and diagnostic devices:
Digital thermometers
Glucometers
Blood pressure monitors
Pulse oximeters
Portable ECG machines
Infusion pumps
Hearing aids
These devices need compact, low-power control with real-
time response—ideal for microcontrollers.
🏭 Industrial Applications
Used extensively for automation, monitoring, and control:
Programmable logic controllers (PLCs)
Robotic arms and CNC machines
Sensors and actuators in process control
Smart meters (electric/gas/water)
Industrial safety systems
Microcontrollers handle sensor input, decision-making, and
actuator control reliably in real-time.
📡 Communication Systems
Embedded in both consumer and infrastructure-level
communication tools:
Mobile phones (peripherals, sensors)
Routers and modems
Remote control transmitters and receivers
Two-way radios / walkie-talkies
IoT communication modules
Bluetooth / ZigBee / Wi-Fi devices
ADVANTSGE OF MICROCONTROLLER
The 8051 is an 8-bit microcontroller developed by Intel.
Think of it like a tiny computer inside your washing
machine, microwave, remote-controlled car, or smart lock
— it takes input, makes decisions, and gives output
automatically.
For example, when you press “start” on your washing
machine: The 8051 reads the water sensor
(input) Calculates how long to wash (processing) Turns on
the motor (output) That’s the 8051
working silently behind the scenes!
Main Features of 8051
1. 8-bit ALU – handles 8-bit data at a time.
2. 4 KB ROM – stores permanent programs.
3. 128 bytes RAM – temporary data storage.
4. 32 I/O lines – for connecting external devices.
5. Dual 16-bit timers – for time and event control.
(a)6. Serial Port – communication with other devices.( 🔌
What is a Serial Port?
A serial port is a communication interface used to send and
receive data one bit at a time, over a single wire or
communication channel.
)
7. 5 Interrupts (2 external, 2 timer , 1 serial) – to handle
emergency tasks.
8. 12 MHz clock – controls execution speed.
Architecture of 8051
The 8051 microcontroller has several important parts:
1. CPU: The brain that processes data.
2. Accumulator (ACC): Stores data for arithmetic operations.
3. Registers (R0–R7): Temporary storage locations.
4. Program Counter (PC): Tracks the next instruction.
5. ROM: Holds the permanent program.
6. RAM: Temporary working memory.
7. I/O Ports: Connects sensors, motors, displays.
8. Timers: Measure time or delay.
9. Serial Port: For communication.
10. Interrupt Control: Handles urgent tasks instantly.
Memory Organization of 8051
8051 has two separate memory spaces:
1. Program Memory (ROM): Stores the program
instructions.
2. Data Memory (RAM): Stores temporary values while
running the program.
It can access up to 64 KB of Program Memory and 64 KB of
Data Memory.
8051 Family Members
8048: 1 KB ROM, 64 bytes RAM
8049: 2 KB ROM, 128 bytes RAM
8051: 4 KB ROM, 128 bytes RAM
8052: 8 KB ROM, 256 bytes RAM + extra time
An accumulator in a
CPU is a register used
for temporarily storing
intermediate results of
arithmetic and logical
operations to enhance
processing speed.
Explain the diagram
ChatGPT said:
Sure! Please upload or paste the diagram you’d like me to explain. Once I can see it, I’ll describe what
it shows, how it works, and the key ideas behind it.
You said:
Uploaded image
Uploaded image
ChatGPT said:
Perfect 👍
You’ve shared two pages showing the architectural block diagram of the 8051 microcontroller and its
memory map.
Let’s go step-by-step to explain the diagram in the first image (Fig. 4.1) — “An Architectural Block
Diagram of 8051”.
🧠 Overview:
The 8051 microcontroller is an 8-bit microcontroller — meaning it processes 8 bits of data at a time.
It has:
4 KB ROM (program memory)
128 bytes of RAM (data memory)
32 I/O lines (for input/output operations)
Timers, counters, and a serial communication port — all integrated into one chip.
⚙️Main Components of the Block Diagram
1. Central Processing Unit (CPU)
ALU (Arithmetic Logic Unit): Performs arithmetic (add, subtract, etc.) and logic (AND, OR, compare)
operations.
Accumulator (ACC): A special register used to store the results of ALU operations.
B Register: Used mainly for multiplication and division.
Program Status Word (PSW): Holds status flags (like carry, zero, overflow, etc.).
Temporary Registers (TMP1, TMP2): Used internally for operations.
Stack Pointer (SP): Points to the current top of the stack in internal RAM.
2. Memory Organization
ROM/EPROM: Stores the program (instructions). It can be 4 KB internal or up to 64 KB external.
RAM: Stores data temporarily. 128 bytes internal (divided into working registers, stack, and bit-
addressable memory).
3. Program Memory & Data Memory Control
Program Counter (PC): Keeps track of the address of the next instruction.
Program Address Register & Buffer: Helps in fetching the instruction address.
PC Incrementer: Increments the program counter after each instruction fetch.
Data Pointer (DPTR): A 16-bit register used to point to external memory locations.
4. Timers and Counters
TCON, TMOD, TH0, TL0, TH1, TL1: Control and data registers for two 16-bit timers/counters (Timer 0
and Timer 1).
Used for time delay generation or counting external events.
5. Serial Communication
SCON (Serial Control Register): Controls serial port operations.
SBUF (Serial Buffer): Holds data for serial transmission/reception.
6. Interrupt Control
IE (Interrupt Enable) and IP (Interrupt Priority) registers manage five interrupts:
Two external interrupts (INT0, INT1)
Two timer interrupts (T0, T1)
One serial interrupt
7. Input/Output Ports
Port 0, Port 1, Port 2, Port 3 (each 8-bit):
Total of 32 I/O lines.
Can be used as input/output or alternate functions (like serial, external memory, etc.)
Each port has:
A latch (to hold data)
drivers (to send/receive signals)
8. Oscillator and Clock Circuit
XTAL1 and XTAL2: Connected to a crystal oscillator, providing the clock frequency (up to 12 MHz) for
timing and synchronization.
OSC block: Generates the necessary clock pulses for the CPU and timers.
9. Control Signals
PSEN (Program Store Enable): Used to read external program memory.
ALE (Address Latch Enable): Used to separate address and data signals in multiplexed lines.
EA (External Access): Chooses between internal and external program memory.
RST (Reset): Resets the microcontroller and initializes registers.
🧩 How It All Works Together
The CPU fetches instructions from ROM using the Program Counter.
Data required by instructions are accessed from RAM or external memory.
The ALU processes data and updates flags in the PSW.
The result is stored in the Accumulator or sent to I/O ports.
Timers, serial port, and interrupts run in parallel to support real-time operations.
Would you like me to explain the second diagram (Fig. 4.2 – Memory Map of 8051) next?
You said:
Explain one real life example connecting this all
ChatGPT said:
Excellent question — this is the best way to truly understand how all the parts of the 8051 work
together 💡
Let’s go through a real-life example step by step.
🚦 Example: Smart Traffic Light Controller using 8051
Imagine you are designing a traffic light system at a 3-way intersection using an 8051 microcontroller.
The system should:
Control Red, Yellow, and Green lights.
Automatically switch lights after a specific time delay.
Allow a manual override button (for police or maintenance).
Send status updates to a remote monitoring unit via serial communication.
🧭 Step-by-Step Connection to the 8051 Architecture
🟢 1. Input/Output Ports (P0–P3)
Port 1: Connected to LEDs for the traffic lights.
Example:
P1.0 → Red Light
P1.1 → Yellow Light
P1.2 → Green Light
Port 2: Connected to sensors or switches.
Example:
P2.0 → Manual Override Button (input)
Port 3: Has alternate functions — we can use it for serial communication (Tx/Rx) to send data to a
monitoring system.
⚙️2. Timers (T0 and T1)
Timer 0 is used to generate accurate time delays (say, 10 seconds for green, 2 seconds for yellow,
etc.).
Inside the block diagram:
The TCON and TMOD registers set the timer mode.
The TH0/TL0 registers count internal clock pulses.
Example flow:
The CPU loads a value into TH0/TL0.
Timer counts up.
When it overflows, an interrupt can signal the CPU to change the light.
🧮 3. CPU, ALU, and Registers
The Program Counter (PC) fetches instructions from ROM.
The ALU executes instructions like “turn ON P1.0” or “check button status.”
The Accumulator (ACC) temporarily holds data like LED states or counter values.
The PSW flags may indicate results (e.g., zero or overflow).
For example:
MOV P1, #01H ; Turn on Red Light
Here, the instruction is fetched from ROM, decoded by the CPU, and the output goes to Port 1.
🧠 4. Memory (ROM and RAM)
ROM stores the program (machine code for controlling lights).
RAM holds temporary data such as:
Current state (Red/Yellow/Green)
Timer values
Interrupt flags
5. Interrupt System
If the manual override button is pressed, it triggers an external interrupt (INT0).
The CPU stops its normal sequence and jumps to a special routine that handles the manual override.
Example:
ORG 0003H ; External interrupt 0 vector address
CALL MANUAL_MODE
RETI
🔄 6. Serial Communication (SCON, SBUF)
The 8051 sends the current traffic light status to a remote monitoring computer.
Example: Every 5 seconds, it transmits “RED ON” via the Tx pin using the SBUF register.
⏰ 7. Oscillator (XTAL1 & XTAL2)
Provides the clock signal (e.g., 12 MHz) that drives the entire timing of the system — instruction
execution, timer counting, and serial communication speed.
🔌 8. Control Signals
RST (Reset): When power is turned on, it resets the microcontroller and initializes all registers.
EA (External Access): If external program memory is used, this pin selects it.
PSEN (Program Store Enable): Reads program instructions from external memory if needed.
ALE (Address Latch Enable): Helps separate address and data when using external memory.
🧩 Putting It All Together — The Flow
On reset, the CPU starts executing instructions from ROM (address 0000H).
Port 1 outputs control signals to traffic lights.
Timer 0 runs continuously, controlling delay intervals.
External interrupt (INT0) checks for a manual override.
The ALU and Accumulator handle logical decisions (like light transitions).
Data is temporarily stored in RAM.
The system reports status through serial communication using SBUF.
✅ Real-World Outcome
The 8051 keeps cycling through:
Red → Green → Yellow → Red, etc.
Each color lasts for a fixed time, controlled by the timers.
If a police officer presses the override switch → interrupt changes the system mode.
The system continuously sends status updates through serial port communication.
Article II. Advanced Projects using 8051 MicrocontrollerÂ
So let’s begin with a list of Advanced Project Kits using 8051 Microcontroller. Advanced projects are
feature rich, full of functions and are an ideal choice for Main Project Work fulfilment of Engineering
Level and Diploma courses. Advanced Level projects always find great application and usefulness in
real-world. Advanced Projects helps an Engineering Student to learn how to build a real-world
application or to solve a real-world problem.
1. Electronic Voting Machine using 8051 – is a very interesting real-world application designed as a
project kit. This project kit is an exact model of Electronic Voting Machines used for conducting
Elections all over the world. Just like real world elections are conducted; there is a presiding officer
control to regulate voting process. The presiding officer control is setup using 3 keys where the first
key is to start voting process, 2nd key is to activate ballot unit for voting and 3rd key is to stop voting
process and start counting. Upto 8 candidates can be setup in the voting machine as contestants. A
32KB memory unit is provided to store each candidates vote count. The voting machine is equipped
with memory lock facility that if some one steals the machine and installs a new memory (with
preloaded values of voting), the machine will not accept the new memory and displays an error
message accordingly.
1. x
Pause
Unmute
Fullscreen
2.
1. Now Playing
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
x
Play Video
Reverse parking Alert Project | Beginner project / School Level Project | #atribot
Watch on
Reverse parking Alert Project | Beginner project / School Level Project | #atribot
2. RFID Based Access Control System – is a very useful project making use of RFID Reader, RFID Tags
and Serial Communication of 8051. We all have seen RFID based Access Control devices in hospitals,
banks, IT parks, Software Companies and in many other buildings. This project is a model of real-
world RFID based Access control devices. In this project kit, we store the unique RFID Tags of
employees or other personnel inside the program memory of 8051 microcontroller. When an
employee with the right RFID Tag swipes his/her tag near the RFID Reader, access will be granted.
Otherwise, access will be denied by the system
3. Heart Rate Monitor using 8051 – is a very useful health/medical application project kit. This
project kit is a model of Heart Rate Measuring devices we see in hospitals, especially inside ICU
(Intensive Care Units). Heart Rate Monitor project kit is designed on the principle of
Photoplethysmography (which is the process of optically estimating volumetric measurement of an
organ). The device senses the heart rate from the finger tip using IR reflection method and displays
it on a 16×2 LCD display in beats per minute. This project kit is very unique and is ideal for students
taking Bio Medical courses like Bio Medical Engineering.
4. Digital Tachometer using 8051 –  This project kit is a digital tachometer which can be used to
measure the revolutions per minute (RPM) of any object like a rotating wheel or a disc or a shaft. We
have seen tachometers in our bikes, cars, engines and many such devices. This application built using
8051 micro controller can measure upto 255 revolutions/second with an accuracy of 1 rev/sec. The
project kit has 3 important sections – 1) the optical pickup designed to pick revolutions of the object
using a phototransistor and LED, 2) Â the processing stage designed using 8051 and the associated
software, 3)  the output display section using 16×2 LCD display and the relay to actuate an output
action.
5. Automatic Plant Watering System – is an interesting project for hobbyists and academics alike. In
this tuotorial, we explain how to make a DIY automatic plant watering system using YL69 moisture
sensor probe, YL38 comparator module and 8051 microcontroller.
Article III. Medium Level Projects using 8051 Micro ControllerÂ
Medium level projects are ideal choices for Mini Project Work fulfilment of Engineering and Diploma
course students. Medium level projects offer a good learning experience and are cornerstones to
successfully building a Main Project Work. Like Advanced projects, Medium level projects also
feature rich and functional real-world applications. The only difference between them is that
Medium Level Projects can be understood/implemented in lesser time compared to Advanced Level
projects.
1. Ultrasonic Range Finder using 8051 – This project as the name says, is an application to measure
the distance of an object from the range finder device. The project kit makes use of an ultrasonic
transducer module HC-SR04 to measure the distance. This project kit can be enhanced to make
applications like Automotive Parking System, Obstacle Warning Systems, Terrain Monitoring Robots,
Obstacle Avoidance Robots etc. This ultrasonic range finder can measure distances upto 2.5 meters
with an accuracy of 1 cm.
2. Solar Panel/Sun Tracker using 8051 - is a very useful real-world project which is relevant in our
times. The objective of this project kit is to track direction of Sun and turn the solar panel accordingly
where maximum light is incident on the panel. This project kit makes use of an LDR pair to track
sunlight and solar panel is moved in steps using a stepper [Link] 16×2 LCD displays direction of
motor rotation as motor rotating left or right. This project kit is an ideal setup to ensure maximum
efficiency from a solar panel unit.
3. Water Level Controller using 8051 – Â This is one of the most popular projects we have developed
using 8051 microcontroller. This water level controller monitors the level of the overhead tank and
automatically switches on the water pump whenever the level goes below a preset limit. The level of
the overhead tank is displayed on the 16×2 LCD module and the pump is switched OFF when the
overhead tank is filled. Â We have given an illustrated circuit diagram with working explained in
detail.
4. Gas Leakage Detector using 8051 -Â is an interesting project which finds real-world application in
home kitchens, hotels and other places where gas leakage is a common issue. This project kit is
designed using MQ2 gas sensor which senses any type of LPG. When LPG leaks, the MQ2 gas sensor
will be activated. 8051 controller in the project kit identifies this and actuates the shutdown
mechanism by turning output relay ON. The 16×2 LCD displays messages when a gas leak is detected.
This project is very useful in realworld and it saves lives.
5. Password Based Home Security System -Â is a real-world application very similar to RFID based
Access Control System. In this project kit, we use a 4×4 keyboard for checking security access instead
of RFID reader and tag. A password is preset and stored in the program memory of 8051
microcontroller. When a user/employee inputs the correct password and hits Lock/Unlock key access
will be granted. If the user inputs a wrong password and hits Lock/Unlock key, access will be denied.
A solenoid lock can be connected to the output relay to automatically open/close the [Link]
messages are displayed on 16×2 LCD display.
6. RC5 Remote Control Decoder -Â is an interesting project which can be used to decode signals
from an RC5 remote controller. We all have used remote controllers for our TV’s, Air Conditioners
and a lot of other devices. Have you ever wondered what kind of signal a remote sends when you
press the volume+/- button or channel+/- button or a menu button? This project exactly decodes
each button press of an RC5 remote control and displays them as a message on 16×2 LCD display.
This project kit can be enhanced to make remote control activated devices or applications.
7. Line Follower Robot using 8051 – is perhaps the most popular mini project work of all times! Be
an Engineering student or not, a Line Follower Robot attracts everyone irrespective of age and
knowledge. Our line follower robot follows the black line perfectly (draw as many complex circuits as
possible and it will follow!) irrespective of the black line circuit complexity! The pickup is designed
using an LED/LDR pair on Left and Right side of the Line Follower Robot.
8. PC Based Notice Board using 8051 – is an interesting project kit to demonstrate communication
between a personal computer and an external device. This project makes use of serial
communication. Whatever message you send through the RS232 serial port of personal computer
will be collected by the 8051 controller and displayed on 16×2 LCD module.
9. Frequency Meter using 8051 -Â is an interesting academic level project where you can measure
and display frequencies. The project kit has a set of shield wires which when connected to a
frequency generator displays the measured frequency on 16×2 LCD display. Any frequency up to
40Khz can be measured using this frequency counter project kit.
Voltmeter using 8051Â Â Â – We all must have used a multimeter from our young days. Have you
ever bothered to create one? So here is one such an interesting project. A Voltmeter using an 8051
microcontroller. Even though its quite simple and an easy to make one, you shall find it really
interesting. This can be used as an application at the mini project level for engineering and diploma
students. This digital voltmeter can measure 0 to 5 volts and has a sensitivity of  200mV which is a
bit low but this project is meant for demonstrating how an ADC and seven segment display can be
interfaced to 8051 to obtain a digital readout of the input voltage. ADC0804 is the ADC and
AT89S51 is the controller used in this project.
Thermometer using 8051 – This is an interesting project designed to measure temperature using
8051. Its a simple 0-100°C digital thermometer with 1°C resolution using 8051. The circuit is based
on LM35 analog temperature sensor, ADC0804 and AT89S51 microcontroller. LM35 is an analogue
temperature sensor IC which can measure a tem perature range of -55 to 150°C. Its output voltage
varies 10mV per °C change in temperature