You are on page 1of 20

Experiment 6 Lab Manual

American International University- Bangladesh

Department of Electrical and Electronic Engineering
EEE 4219: Computer System Architecture Laboratory

Title: Microcontroller Based System Design

In this section, we will learn
1) Difference between a microprocessor and a microcontroller
2) How to code a simple program in C for ATmega32 Microcontroller
3) How to simulate the code in Proteus and observe the results
Theory and Methodology:
By microprocessor we mean the general-purpose microprocessors, for example, Intel's x86
family (8086, 80286, 80386, 80486, and the Pentium) or Motorola's PowerPC family. These
microprocessors contain no RAM, no ROM, and no input/output ports on the chip itself. For
this reason, they are commonly referred to as general-purpose microprocessors. If you have
to design a general-purpose microprocessor like the Pentium and make them functional, you
must add RAM, ROM, I/O ports and timers externally and place in a board (mother board).
Although the addition of external RAM, ROM, and I/O ports makes these systems bulkier
and much more expensive, they have the advantage of versatility, enabling the designer to
decide on the amount of RAM, ROM, and I/O ports needed to fit the task at hand. For
example, you can upgrade your Laptop RAM from 2GB to 4GB easily.
This is not the case with microcontrollers. A microcontroller has a CPU (a microprocessor) in
addition to a fixed amount of RAM, ROM, I/O ports and timers all on a single chip. In
other words, the processor, RAM, ROM, I/O ports, and timer are all embedded together on
one chip; therefore, the designer cannot add any external memory, I/O port or timer to it. The
fixed amount of on-chip ROM, RAM, and number of I/O ports in microcontrollers makes
them ideal for many applications in which cost and space are critical. The difference of the
microcontroller and microprocessor can best be demonstrated using the following figures







Figure-1: Microprocessor (only the leftmost box). You have to connect other components like
RAM, ROM etc. using data BUS and Address BUS

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)





I/O Port
Figure 2 : Microcontroller (The whole Box). All components are inside the
microcontroller. When you buy microcontroller, you get all components (RAM, ROM
etc.) as built-in inside the chip.
In many applications, for example, a TV remote control, there is no need for the computing
power of an 80486 or even an 8086 microprocessor. In many applications, the space used, the
power consumed, and the price per unit are much more critical considerations than the
computing power. These applications most often require some I/O operations to read signals
and turn on and off certain bits. So, microcontroller will be a good choice in these cases.
Microcontrollers for embedded systems:
Microprocessors and microcontrollers are widely used in embedded system products. An
embedded system is controlled by its own internal microprocessor (or microcontroller) as
opposed to an external controller. Typically, in an embedded system, the microcontroller's
ROM is burned with a purpose for specific functions needed for the system. A printer is an
example of an embedded system because the processor inside it performs one task only;
namely, getting the data and printing it.
In contrast with a Pentium-based PC (or any x86 PC), which can be used for any
number of applications such as word processor, print server, bank teller terminal, video game
player, network server, or Internet terminal. A PC can also load and run software for a variety
of applications. Of course, the reason a PC can perform myriad tasks is that it has RAM
memory and an operating system that loads the application software into RAM and lets the
CPU run it. In an embedded system, typically only one application software is burned into
ROM. An x86 PC contains or is connected to various embedded products such as the
keyboard, printer, modem, disk controller, sound card, CD-ROM drive, mouse, and so on.
Each one of these peripherals has a microcontroller inside it that performs only one task. For
example, inside every mouse a microcontroller performs the task of finding the mouse's
Today, embedded systems are found in cell phones, digital cameras, camcorders,
portable video games, calculators, and personal digital assistants, microwave ovens,
answering machines, home security systems, washing machines, lighting systems, fax
machines, copiers, printers, and scanners, cash registers, alarm systems, automated teller
machines, transmission control, cruise control, fuel injection, anti-lock brakes, active
suspension and many other devices/ gadgets. Hence, learning about the embedded system is a
doorway to learn controlling these devices.
Criteria for choosing a microcontroller:
1. The first and foremost criterion in choosing a microcontroller is that it must meet the task
at hand efficiently and cost effectively. In analyzing the needs of a microcontroller-based
project, we must first see whether an 8-bit, 16-bit, or 32-bit micro controller can best
Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

handle the computing needs of the task most effectively. Among other considerations in
this category are:
a) Speed: What is the highest speed that the microcontroller supports?
b) Packaging: Does it come in a DIP (dual inline package) or a QFP (quad flat
package), or some other packaging format? This is important in terms of space,
assembling, and prototyping the end product.
c) Power consumption. This is especially critical for battery-powered products.
d) The amount of RAM and ROM on the chip.
e) The number of I/O pins and the timer on the chip.
f) Ease of upgrade to higher-performance or lower-power-consumption versions.
g) Cost per unit: This is important in terms of the final cost of the product in which
a microcontroller is used. For example, some microcontrollers cost 50 cents per
unit when purchased 100,000 units at a time.
In this respect, we have chosen either Atmenga32 (or ATmega16) because it can be
operated at moderate speed (up to 8KHz internal clock, also higher external clock), it has
sufficient amount of RAM, ROM for any decent project and has many features like ADC
etc. on a single chip.
2. The second criterion in choosing a microcontroller is how easy it is to develop products
around it. Key considerations include the availability of an assembler, a debugger, a codeefficient C language compiler, an emulator, technical support, and both in-house and
outside expertise. We have chosen ATmega series because a lot of community support is
available online. Many free and efficient compiler and code samples from different
projects are present for ATmega32.
3. The third criterion in choosing a microcontroller is its ready availability in needed
quantities both now and in the future. For some designers this is even more important
than the first two criteria. Currently, AVR and PIC are two most used microcontrollers. In
recent years, companies have begun to sell Field-Programmable Gate Array (FPGA) and
Application-Specific Integrated Circuit (ASIC) libraries for the different microcontrollers.
Familiarization with ATMEGA32:

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

Note that:
Total 4 PORTs (A, B, C, D)
Each PORT has 8 PINS, e.g.,
PORT A has PA7PA0 pins.
PIN 10 is power supply (VDD
= 5V), PIN 11 is GND (0V).
Make sure
connected to 1.

Figure-3: PIN configuration of ATmega32

About The Microcontroller:
Atmega32 has total 40 pins (Look at the pin description of fig. 3). As you can see the pins are
arranged in two sides of microcontroller. This type of package is called Dual-In-Line package
There are 4 ports in ATmega32: PORT A, B, C and D. Each port has 8 pins (0-7). For
example, PORTB has 8 pins from PB0 to PB7. In ATmega32, PB0-PB7 is arranged from 1 to
8 positions.
You can use any port & their pins as output or input. In output mode, you can drive anything
(e.g. LED) from the pins. In input mode, microcontroller can understand the input you give at
the pins (e.g. using a button). So, you have to first set the pin either as input or output.
To control I/O pin of microcontroller, there are three controlling register:
DDRx (Data Directional Register for PORT x),
PORTx (For port Output)
PINx (For Port Input).
Note: they are uppercase. If you are controlling PORT D, then x = D (i.e., DDRD, PORTD
and PIND).
1. Computer System for simulation
2. Proteus Software
3. Atmega-32 Microcontroller

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

Experimental Procedure:
Suppose, a LED is connected to pin 40 and a Button is added to pin 5. How will you set the
controlling register?
1. First set the pin 40 (which is PA0) to Output. To make any pin as output set a 1 at that bit
position. Since PA0 is the 1st bit, make the 1st bit of DDRA as 1. Use the following line:
DDRA = 0x01;
// in Hex
DDRA = 0b00000001;
// in Binary
2. Once the PA0 is set as output, decide what you want to show by this pin. You can show
either 0 or 1.
To set PA0 as high
PORTA = 0x01;
PORTA = 0b00000001;
To set PA0 as low
PORTA = 0x00;
PORTA = 0b00000000;


Figure-4: Microcontroller as input and

A button is connected to pin 5 (PB4). When the button is pressed, either 0 or 1 is connected
with this pin. To use this pin as input
1. First set the pin 5 (which is PB4) to INPUT mode. To make any pin as input, set a 0
at that bit position. Since PB4 is the 4th bit, make the 4th bit of DDRB as 0. Use the
following line:
DDRB = 0x00;
// in Hex
DDRB = 0b00000000;
// in Binary

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

2. Once the PB4 is set as input, check whether the pin is high or low using if clause
if ((PINA&0b0001000) == 0) // If PB4 is zero, then using AND with 1 will be 0
// code when button sends zero (PB4 = 0)
else if ((PINA&0b0001000) == 1) // If PB4 is 1, then using AND with 1 will be nonzero
// code when button sends high (PB4 = 1)
___________________________________ _______________
Our first Project: we will write a code that will blink a LED.
Circuit Connection: Suppose, a LED is connected to PORTB at PIN B0 (i.e. at PIN 1, see fig.
First we have to select the language; we can use either assembly or C to write the code. But
the microcontroller only understands Intel Hex format. So, we will use a compiler that will
convert the code (Written in assembly or C) into a Hex file. Then we will download the Hex
file into the flash memory of the microcontroller. The microcontroller will run according to
the code.
The size of the hex file produced by the compiler is one of the main concerns of
microcontroller programmers because microcontrollers have limited on-chip Flash memory.
For example, the Flash memory space for the ATmega32 is 32K bytes.
What should you choose between C and Assembly depends on the need of the project. The
following table shows the difference between the languages (Assembly and C)
hex file generated by the assembler is
much smaller
1. Programming in Assembly language is
often tedious.
2. Programming in Assembly language
takes a lot of time and patience.


Hex file generated by the compiler is
It is easier and less time consuming to
write in C than in Assembly.
C is easier to modify and update.
You can use code available in function
C code is portable to other
microcontrollers with little or no

Since, we have 32KB of memory to use (It is actually a lot of memory), Hex file size will not
be a concern for our LED blinking program. For all the benefit promised from C language,
we will use the C programming language to code.
Second, we have to use a compiler that will convert our C code to Hex file so that
microcontroller can read the Hex file and work accordingly. There are several compilers like
AVR GCC & AVR Studio, Micro C, Raisonance Kit (Ride) etc. AVR GCC & AVR Studio
are a good compiler you can use, but we will use MicroC because MicroC has a lot of built-in
libraries that will help you a lot, as you will see later.
Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

Finally, before start coding, lets review about the data types of C language.

Data Type
unsigned char
unsigned int
unsigned long

Size in Bits

Data Range
0 to 255
-128 to + 127
0 to 65,535
-32,768 to +32,767
0 to 4,294,967,295
-2,147,483,648 to +2,147,483,648
1.175e-38 to 3.402e38
1.175e-38 to 3.402e38

As you can see, there are total 8 data types. Use data types wisely. Suppose, you want to save
your age in a variable, which data type will you use? Suppose, you declare a variable named
age like this:
unsigned int age;
Now, from the table you can see, the age variable you declared can vary from 0 to 65,535.
But, you can expect to live up 120 years at best. Unless you have found some way to live
over thousand years (!), you should use the 1st data type (unsigned char, 8 bit range up to
Whats the benefit of using smaller data types?
Instead of using 16 bit unsigned data, you are using only 8 bit char. So, you have saved (16
bit 8 bit) = 8 bit data (1 byte). You may think, in a world of terabyte, saving 1 byte is not a
big deal. But in a world of microcontroller where you have 32Kbytes of code memory, saving
1 byte is a big deal. Even if you were coding a microcontroller with 1 Terabyte memory, you
should always try to use less memory as you can. Never waste the resources, even it is 1 bit.
This will make the difference of an efficient coder and a bad coder.
Using MicroC for AVR:
1. Open Micro C compiler. Go to: Project menu > new project (Shortcut: Ctrl + Shift + n).
Press next to continue.

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

Always try to learn the shortcuts commands. They will increase your efficiency.

2. Step 1 & 2: Select your microcontroller as Atmega32. Select clock source as 8 MHz.
This will be the clock source for the CPU instructions.
3. Step 3: Save your project with a name that shortly says the function of the code (e.g.
It is wise to create a folder with your section and group no (like section B Group 8)
inside some directory. Some of your project may be needed later. So, if you are
organized and have saved your work properly with proper name, it will help you in your
report writing and in completing future projects.

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)

4. Step 4, 5 & 6: For this point, just press next to step 4 (i.e. you dont want to add any file
in your project). For step 5, select Include all and press next. Press finish (step 6).

You will see the following window:

From your experience with the C programming language, you know that the main function
is the principal function that will be executed by the Microcontroller once.
Write the following code in the code window:

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Linebyline Explanation of the code:

1. DDRB = 0x01;
You have added LED to port PB0. So, you will want to make that port as output port.
To set PB0 as output, change data directional register for that port to 1. Look at the table
below to see how it is done:
DDRB (Data Direction Register for PORT B)
You need to set PB0 as output. So, making PB0 = 1 (keeping PB7-PB1 = 0) will result in
00000001 in binary or 01 in hex. This tells the compiler that set only pin B0 as output and
set others as input
Note that 0x indicates the number following 0x is in hexadecimal. You can use also binary
notation like: DDRB = 0b00000001; (note 0b indicates binary)
2. while (1){ }
The purpose of the while code block is to engage the microcontroller in running the code
repeatedly. If you do not use while, the microcontroller will run the code for one time, this
means LED will blink for only one time. But we want to blink it again and again. Hence, we
have to use an infinite loop that will blink the LED repeatedly. Look the argument inside
while is 1 (or true), this indicates that the condition of while is always true. So, the code
inside the while will run forever.
Note 1:

We will always use a forever running while loop and keep the microcontroller
busy. If we do not use it, main function will run only once. Then the
microcontroller will get out of the main function and will not do anything (be

Note 2:

you can also use for (;;) or do-while (1) code block to make an infinite loop.
They are equivalent and different programmer like different styles.

3. PORTB = 0x01;
Up to now, you have set PORT B0 as output. That means you can set the output either 0 or 1
and use that port to drive a LED. If you set 1, the output port will get power (+5V). For
Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


setting 0, output port will have no power (0V). So, PORTB = 0b00000001 will make the
output LED to be on. To make the LED off, set PORTB = 0b00000000.
LED connected
at PB0









4. Delay_ms(1000)
This is a built-in function in MicroC that will give a delay of 1000ms (or 1s).
Why you have to use that delay? Consider the following two cases of delay:
Case I: If you give the delay, the code will run like this
LED: on Keep LED on for 1s LED off Keep LED off for 1s LED on ..

The change will be slow and your eye will be able to see the blinking (on-off of LED).
Case II: If you do not give any delay, the code will run like this
on off on off on off on off on off

This means the LED will turn on and off too fast (since there is no delay between on and off).
Our eyes cannot detect too fast change and we will see the LED is always on (although the
LED is actually blinking very fast).
You can now see the reason of using MicroC. It has built-in Delay_ms function that
automatically gives delay in milisecond; you do not have to write the function by yourself. If
you want to create a delay function by yourself, you can use for loop
unsigned int i;
For (i=0; i <= 65535; i++)
// empty for loop that does nothing, but will
// keep microcontroller busy
The problem of using for loop to create delay is that it is difficult to set delay time like 1s, 5s.
It depends on clock source, processor etc. Using Timer is a good alternative to create delay.
For now, use Delay_ms ( ) or Delay_us ( ) to create time delay in ms or s respectively.
5. // .
Anything after the double slash sign (//) will be ignored by the compiler. You will use this for
commenting throughout your code. A good coder always comments in his/her code in a
meaningful way.
Do not comment something obvious like:
PORTB = 0x01;
// Making PB0 = 1
Rather use comment so that it can help others in reading & understanding your code:
PORTB = 0x01;
// setting PB0 as output, driving a LED

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Lets summarize the algorithm and code:

void main() {
DDRB = 0x01;
// Set direction to be output

PORTB = 0x01;
PORTB = 0x00;


while (1) {

Main function to be run by Microcontroller

Set the PB0 pin as output (now, it can give

either 0 or 1)

Run the code inside the while block

infinitely. (So, inside the block we will write
the code of blinking LED for one time,
while will run that repeatedly)

Turn the LED on that is connect to PB0

Wait a second

Turn the LED off

Wait a second. Thus 1 blink is complete.

Then go the beginning of while loop and

start again.

After you have entered the code in the compiler, go to menu: Project build (ctrl+F9). This
will create a hex file in the file location where you have saved your project. The Hex file has
to be loaded to microcontroller to see the effect of LED blinking code.
Simulating the Code in Proteus:
Open Proteus (Go to Start Menu, find Proteus and click ISIS 7 professional). You will see a
window like below. You can see in the left panel, there are many tools. The tools that we will
use mostly are shown in the image below. We will discuss only the tools we will need for this

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Figure-5: Familiarization to Proteus Interfaces and tools

Figure-6: Picking a component from library

Selection mode: To select the parts or components in your design space.
Component mode: There are a lot of components in Proteus. If you want a component, say
you want a LED in your simulation, then click component tool and select P at under the
device entry (or shortcut: Select component, then press p from your keyboard). Note that,
P means you are going to pick a component from a list of components stored in Proteus
Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


After pressing P, you will see a search box, enter text LED and search. You will find a
variety of LEDs. For our purpose, select LED-RED and press ok (see figure below).
Subcircuit mode: you can divide the circuit in different sections and represent each
section/block in a subcircuit. This makes the design simpler to observe and manage in
hierarchical way. We will not use subcircuit for such simple LAB, but for complex design,
e.g. if you are designing a 4 bit PC in Proteus, you have to use subcircuit to keep your design
neat and accessible.
Terminal Mode: When you want to give
POWER and GROUND to any pin of
device, select this mode. Suppose, you
want to give ground to your LED, look the
following image how it can be done. Just
click on the GROUND and click on the
design space on the right. You will see
your cursor is now a GROUND. Place the
ground where you want.

To connect the LED and the GROUND,

place your cursor at the end of ground or at
the end of LED terminal. Your cursor will
turn in a pencil. Click (do not press and
hold, just click once) and complete the

Figure-7: Terminal mode to pick a ground or

Power supply

If cursor does not turn into pencil automatically, make sure you have selected
the component or terminal mode.

Now, complete a connection like the following

select component mode

connection: by moving
cursor near the pins.
Remember, you wrote
the code to blink a
LED using PB0 pin.
Give a ground at the
other end of LED
Figure-8: Connection of LED with microcontroller

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


You are almost done! Double click the microcontroller in your design a dialog box name
edit component will open. (See figure-9)
Select the folder icon in the program file and show the hex file you generated
Select clock source (CKSEL FUSES): (0100) Int. RC 8 MHz.

Figure-8: Editing component

Figure-9: Connection Indication

Now, run the simulation by pressing the Play button at the bottom of the design window.
Add a voltage probe (see figure below) and an oscilloscope (in the virtual instruments mode)
to PB0 pin. Use channel A (or any other) of the oscilloscope.
Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Figure-10: Adding Measuring Instruments

Inside the virtual oscilloscope (see image below), you will see three options: auto, one shot
and cursor. Auto will always update the channel. One shot will take the voltage reading
from the channel only for one time. Selecting cursor, you can measure different points in
the display pulses.

If the oscilloscope does not show the display window, right click on the
oscilloscope and select Virtual Oscilloscope from the pop-up menu.

Press one shot and change voltage magnitude and time axis to see the pulse you are
generating by the code that actually makes the LED blink. The analog voltage level can also
be seen at voltage probe.

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Figure-11: Oscilloscope connection



Simulation in Proteus is quite real time (i.e. if you face a problem in Proteus, you will also
see the same problem in Hardware). Also, you can check your code over and over again
before building your circuit. But when you give connection of your circuit and download
your Hex file to Microcontroller, you have to consider certain conditions. Lets upgrade our
simple project.
Upgrade 1: Use microcontroller as source or sink:
r as




Figure-12: Microcontroller can supply current as driver or take current

from source as sink

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Microcontroller (fig. 12) When PB0 = high (+5V)

(Left LED is on. Current will flow
from microcontroller to the
ground through LED. So,
microcontroller is the source
(supplying current)
(Right LED is off, because voltage
difference of the LED is
(5V-5V) = 0.

When PB0 = low (0V)

LED is off, because voltage
difference of the LED is zero.

LED is on. Current will flow

from power supply (+5V) to the
microcontroller pin (PB0)
microcontroller is the sink
(Taking current)

In real life, microcontroller is used only for controlling (As you can see, it has controller in
its name!). It is not good for driving components (i.e. to give currents). Taking too much
current will damage the microcontroller. So, always use to design your circuit where
microcontroller works as sink.

look at the table above that when PB0 = 5V, the LED is off and when PB0 =
0V, the LED is on (Inverse logic: Our code says when PB0 is 5V, LED will be
on). Since our code is to blink the LED (on and off alternately), we do not
have to change the code here. But, you may want to change your comments so
that you can remember you are using Microcontroller as sink:
PORTB = 0x01;

// Turn OFF diodes on PORTB

Upgrade 2: Always Use current limiting resistors:

Running the LED at its rated normal forward current will produce its rated light and assure a
long prosperous life for it. Running a LED above its maximum ratings will destroy it.
In this LAB, we are using 5V across the LED to light it up. This will not cause problem for
now, but in the long run, it might damage the LED. See your text book, to learn how to
calculate the current limiting value of resistors. For this LAB, use 220 resistor in series with
LED so that excess voltage is taken by the resistor and the current in that branch is limited by
the resistance. Your modified schematic will be like this

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Figure-13: Use of current limiting resistor in series with LED

In simulation, we did not give power to microcontroller. The simulator knows the power pin
of microcontroller and use power internally. But, in actual hardware connection, you have to
give power to ATmega32.
Look at the pin diagram of microcontroller (fig. 3).
Connect +5V to PIN 10.
Connect GND to PIN 11.
Connect +5V to RESET pin 9.
pin is used to reset. If given 0, it will reset the code in microcontroller and start again
from main function. We do not want to reset the controller. So, make this pin high (inactive).
Good Reset circuitry is another feature of good project. Good reset circuit ensures that when
reset is pressed, the processor will reset only one time (sometimes the reset pin senses spikes
or bounces in input and reset several times). Think about your PC. If you press reset (Restart)
and the PC restarts several time, that will be a faulty design. Hence, in real time project, use
good reset circuit with capacitors so that it can prevent any spikes in reset pin. For this simple
LAB, the reset will be simple: connect directly to HIGH.
Connect your circuit with microcontroller. The microcontroller still does not know what to
do. We know what to do: lets burn some microcontroller! By burning (means writing) the
hex file generated from our code to its ROM, the microcontroller will know how to behave
according to the code. This is similar to Proteus. We loaded the hex file to ATmega32, now
we will load it to hardware.
To download the Hex file, we will use a device named TOPWIN, which is a universal burner
(means it can handle microcontroller from different family). But here also a lot of variety
exists. You can use different burning software like Extreme Burner, software with Micro C or
AVR studio. The downloading hardware can also vary. TOPWIN is just one of the many
universal programmers. You can even build a programmer/burner/MC writer of your own.
Several such circuits exist over Internet.

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)


Place your microcontroller in TOPWIN and use the software supplied with TOPWIN to write
the hex file. Be sure you have set the clock source as internal and same as you used in your
C code.
Simulation and Measurement:
1. Suppose a push switch is connected at PB0 and A LED is connected to PD0.
a. Write a complete C code in MicroC that will blink the LED when the switch is
pressed only.
b. Simulate the code in Proteus and ensure it works perfectly.
c. Implement the project in Breadboard
Equipment: ATmega16 or ATmega32 (1), wires, Resistors (220 ohm) (1), Topwin
Burner, Push button (1)
2. Implement a project named Knight Rider LED. In this project use total 8 LEDs in
PORTD. When the switched is pressed, the middle LED will turn on. Then the right LED
will only be turned on, till the end. Then the lighting LED will come to left side.
Use the 8 LED table below. Follow the numbering to note how the LEDs are turning on (Start
from 1, end at 16, then again start from 1)
N.B. only one LED will be on at a time.
1. Search 7SEG-BCD in the Proteus library and complete the connection as shown
2. Note that 7SEG-BCD is connected to PB3-PB0. So, first set these PINs as output.
3. Then in your infinite while loop, first show first digit of your ID (e.g. 1). Note that the
7SEG-BCD takes input as hex and give the output. To show 1, you have to set PB3PB0 = 0001. If you want to show 9, set PB3-PB0 = 1001 (binary of 9).
4. Do not forget to give delay between the digits.
After showing your ID, show the letters of your department character by character (EEE, CSE
Questions for report writing:
Add a switch at PB7 (search Proteus model Logic State It will give 0 or 1 to PB7 pin).
When PB7 is 1, the operation will be as before. If PB7 = 0, your ID and department will be
seen in reverse order (e.g. 1209-1359-2 CSE will be 2-9531-9021 ESC in reverse).
During the project show at next LAB, bring
1. Proteus file containing circuits (.DSN) and MicroC project file with C code (To show
your effort to the faculty)
2. Printed copies of your code (.C) file and design file (Proteus file)
3. Your short Report explaining your code and design

Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB)