You are on page 1of 14

E

EXPERIMENT REPORTS
MICROCONTROLLER

Experiment Title

: Keypad Input with LED display

Experiment Number : 02
Lab. worker

: Annisa Fatioka

Student Number

: 1211012005

Class / Group

: III EI D4 / VIII

Co. worker

: Almaidah

Supervisor

: 1. Era Madona,SST.,M.Sc
2. Muhammad Irmansyah,ST.,MT

ELECTRICAL ENGINEERING
D IV INDUSTRIAL ELECTRONICAL
STATE POLYTECHNIC OF PADANG
2014/2015

DI
V

APPROVAL PAGE

Experiment Number

: 02

Experiment Title

: Keypad Input with LED display

Lab. Worker

: Annisa Fatioka

Student Number

: 1211012005

Department/Study Program

: Electrical Engineering / D IV Industrial Electronical

Class

: III D IV EC

Group

: VIII

Co. Worker

: Almaidah

Experiment Date

: April, 6th 2015

Submission Date

: April, 13th 2015

Supervisor

: 1. H.M.Irmansyah, ST., MT
2. Era Madona, SST., M.Sc

Score

PREFACE

All praise be to Allah SWT for the bless and gift to the writer to finish the report
well. The experiment title is Keypad Input with LED Display. This report is the result
of experiment in the Microcontroller and Interface II laboratory.
The writer would like to thank Mr. H.M.Irmansyah, ST., MT and Mrs.Era Madona, SST.,
M.Sc as supervisors who have given instruction and direction to the writer in experiment, and
all who have contributed.
This report still has some weakness, therefore work the writer hopes critic and
suggestion to improve any reports in the future. Finally, the writer hopes this report to be
useful for the writer and the readers.

Padang, April, 9th 2015


The writer

Annisa Fatioka

TABLE OF CONTENT

Approval Page
Preface
Table of contents
Chapter I Introduction
1.1 Purpose of experiment
1.2 Theoretical Background
Chapter II Experiment
2.1 Tools and Materials
2.2 Work steps
2.3 Programs
Chapter III Result of Experiment
3.1 Data
3.2 Analysis
Chapter IV Conclusion
4.1 Conclusion
4.2 Suggestion
Bibliography

CHAPTER I
INTRODUCTION

1.1 Purpose of Experiment


After doing this experiment, hoped that students:
1. Understand how the operation of the AVR microcontroller system ATMEGA8535
2. Understand how to operate the system microcontroller AVR ATMEGA8535.
3. Taking the input data from the program keypad and display it on the LED by using the
system microcontroller AVR ATMEGA 8535.
1.2 Theoretical Background

Keypad is an arrangement of push-button switch according to the rows and columns.


The shape and arrangement of the keypad can be seen in the circuit 7. From circuit 7, to know
where the switch is pressed by checking the rows and columns. For example switch SW10

(on the numeric keypad 8) then the line 3 (PD2) connected to column 2 (PD5). So that the
microcontroller to know which rows and columns are connected, then most microcontroller
ports functioned as output and partly function as an input. In Circuit 7, PD4-PD7 (high order
nibble port) functioned as output and PD0-PD3 (low order nibble port) functioned as an
input, make sure when no key is pressed, the microcontroller reads a logic '1'. Results keypad
key presses will be issued on the LED so that the LED lights up that is connected to PORTA.

CHAPTER II
EXPERIMENT

2.1 Tools and Materials

Module Atmega 8535


Keypad
Cables

2.2 Step Of Experiment


1. Create program at CodeVision AVR
2. Write program in Editor C, and save it.
3. Compile the program by pressing the F9 key(Compile) or via menu Project and
select Compile.
4. Make the circuit on board microcontroller system module.
5.

Make hex file from program that has been created.

2.3 Programs
Program 1
#include <mega8535.h>
#include <delay.h>
unsigned char key;
unsigned char scan_keypad();
void main(void)
{
PORTA=0x00;
DDRA=0xFF;
PORTD=0xFF;
DDRD=0xF0;
while(1)
{
PORTA=0xff;
key=scan_keypad();
if (key=='1')
{
PORTA=0b00000001;

delay_ms(500);
}
if (key=='2')
{
PORTA=0b00000010;
delay_ms(500);
}
if (key=='3')
{
PORTA=0b00000011;
delay_ms(500);
}
if (key=='4')
{
PORTA=0b00000100;
delay_ms(500);
}
if (key=='5')
{
PORTA=0b00000101
delay_ms(500);
}
if (key=='6')
{
PORTA=0b00000110;
delay_ms(500);
}
if (key=='7')
{
PORTA=0b00000111;
delay_ms(500);
}
if (key=='8')
{
PORTA=0b00001000;
delay_ms(500);
}
if (key=='9')
{
PORTA=0b00001001;
delay_ms(500);
}
if (key=='*')
{
PORTA=0b00001010;
delay_ms(500);
}
if (key=='#')
{
PORTA=0b00001011;
delay_ms(500);
}
if (key=='A')
{
PORTC=0b00001100;
delay_ms(200);
}
if (key=='B')
{
PORTC=0b00001101;
delay_ms(200);
}
if (key=='C')
{

PORTC=0b00001110;
delay_ms(200);
}
if (key=='D')
{
PORTC=0b00001111;
delay_ms(200);
}
if (key=='0')
{
PORTC=0b00000000;
delay_ms(200);
}
}
}
unsigned char scan_keypad()
{
PORTD=0b11101111;
if(PIND.0==0) return ('A');
if(PIND.1==0) return ('4');
if(PIND.2==0) return ('7');
if(PIND.3==0) return ('*');
PORTD=0b11011111;
if(PIND.0==0) return ('1');
if(PIND.1==0) return ('5');
if(PIND.2==0) return ('8');
if(PIND.3==0) return ('0');
PORTD=0b10111111;
if(PIND.0==0) return ('2');
if(PIND.1==0) return ('6');
if(PIND.2==0) return ('9');
if(PIND.3==0) return ('#');
PORTD=0b01111111;
if(PIND.0==0) return ('3');
if(PIND.1==0) return ('B');
if(PIND.2==0) return ('C');
if(PIND.3==0) return ('D');
}

Program 2
#include <mega8535.h>
#include <delay.h>
unsigned char key;
unsigned char scan_keypad();
void main(void)
{
PORTA=0x00;
DDRA=0xFF;
PORTD=0xFF;
DDRD=0xF0;
while(1)
{
PORTA=0xff;
key=scan_keypad();
if (key=='1')
if (key=='3')
{
PORTA= 0b00000001;
delay_ms(200);
PORTA= 0b00000010;
delay_ms(200);
PORTA= 0b00000100;

delay_ms(200);
PORTA= 0b00001000;
delay_ms(200);
PORTA= 0b00010000;
delay_ms(200);
PORTA= 0b00100000;
delay_ms(200);
PORTA= 0b01000000;
delay_ms(200);
PORTA=0b10000000;
delay_ms(200);
PORTA= 0b01000000;
delay_ms(200);
PORTA=0b00100000;
delay_ms(200);
PORTA=0b00010000;
delay_ms(200);
PORTA=0b00001000;
delay_ms(200);
PORTA=0b00000100;
delay_ms(200);
PORTA=0b00000010;
delay_ms(200);
PORTA=0b00000001;
delay_ms(200);
}
};
}
unsigned char scan_keypad()
{
PORTD=0b11101111;
if(PIND.0==0) return ('A');
if(PIND.1==0) return ('4');
if(PIND.2==0) return ('7');
if(PIND.3==0) return ('*');
PORTD=0b11011111;
if(PIND.0==0) return ('1');
if(PIND.1==0) return ('5');
if(PIND.2==0) return ('8');
if(PIND.3==0) return ('0');
PORTD=0b10111111;
if(PIND.0==0) return ('2');
if(PIND.1==0) return ('6');
if(PIND.2==0) return ('9');
if(PIND.3==0) return ('#');
PORTD=0b01111111;
if(PIND.0==0) return ('3');
if(PIND.1==0) return ('B');
if(PIND.2==0) return ('C');
if(PIND.3==0) return ('D');
}

CHAPTER III
RESULT OF EXPERIMENT
3.1 Data
Display 1
N
O
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Keypad Button

LED Display

1
2
3
4
5
6
7
8
9
*
#
A
B
C
D
0

00000001
00000010
00000011
00000100
00000101
00000110
00000111
00001000
00001001
00001010
00001011
00001100
00001101
00001110
00001111
00000000

Display 2
Keypad Button

1 and 3

LED Display
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000
01000000
00100000
00010000
00001000
00000100
00000010
00000001

3.2 Analysis
At this experiment we create programs to input keypad with LED display that connected
directly to the atmega8535. The program that we created will show two different display.
At every program we enter the instruction #include <mega8535.h> library because we use
atmega 8535.
In the first experiment, we activate the LED in accordance with the given input keypad.
When we press switch 1, then the LED display the binary of number 1. When we press
switch 2, then the LED display the binary of number 2. It also work in the next number of
the process.
In the second experiment, we activate the LED running with input keypad (as password)
depend of what we want (at least 2 characters). We use the numbers 1 and 3 as passwoard.
So, if we press the 1 and 3 on the keypad, then the LED will be running. But if we press a
button other than 1 and 3, then the LED will not light.

CHAPTER IV
CONCLUSION
4.1 Conclusion

CodeVision AVR basically able to translate the language C.

The structure of the C language consists of 4 blocks; Header, declarations constants,


functions, and the last major program

For the activation of LED with the input keypad using AVR can be applied in
everyday life, such as: the provision of a password to something.

4.2 Suggestion

Learning theoretical background first is better to fluent experiment.


Checking tool and material before begin the experiment

BIBLIOGRAPHY
Tim Microcontroller. 2012. Microcontroller and Interface. Padang: PNP

You might also like