17
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 EXPERIMENT REPORTS MICROCONTROLLER E D

Experiment Reports

Embed Size (px)

DESCRIPTION

english reportmicrocontroller

Citation preview

EXPERIMENT REPORTSMICROCONTROLLERECDIV

Experiment Title: Keypad Input with LED display Experiment Number: 02Lab. worker: Annisa FatiokaStudent Number: 1211012005Class / Group: III EI D4 / VIIICo. worker: AlmaidahSupervisor: 1. Era Madona,SST.,M.Sc2. Muhammad Irmansyah,ST.,MT

ELECTRICAL ENGINEERINGD IV INDUSTRIAL ELECTRONICAL STATE POLYTECHNIC OF PADANG2014/2015

APPROVAL PAGE

Experiment Number: 02Experiment Title: Keypad Input with LED displayLab. Worker: Annisa FatiokaStudent Number: 1211012005Department/Study Program: Electrical Engineering / D IV Industrial ElectronicalClass: III D IV ECGroup: VIIICo. Worker: AlmaidahExperiment Date: April, 6th 2015Submission Date: April, 13th 2015Supervisor: 1. H.M.Irmansyah, ST., MT 2. Era Madona, SST., M.ScScore:

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 PrefaceTable of contentsChapter I Introduction1.1 Purpose of experiment 1.2 Theoretical BackgroundChapter II Experiment2.1 Tools and Materials2.2 Work steps2.3 Programs Chapter III Result of Experiment3.1 Data3.2 Analysis Chapter IV Conclusion4.1 Conclusion4.2 SuggestionBibliography

CHAPTER IINTRODUCTION

1.1 Purpose of Experiment

After doing this experiment, hoped that students:1. Understand how the operation of the AVR microcontroller system ATMEGA85352. 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 IIEXPERIMENT

2.1 Tools and Materials Module Atmega 8535 Keypad Cables

2.2 Step Of Experiment

1. Create program at CodeVision AVR2. 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

#include

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=0b00000101delay_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 #include

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 IIIRESULT OF EXPERIMENT

3.1 DataDisplay 1NOKeypad ButtonLED Display

1100000001

2200000010

3300000011

4400000100

5500000101

6600000110

7700000111

8800001000

9900001001

10*00001010

11#00001011

12A00001100

13B00001101

14C00001110

15D00001111

16000000000

Display 2Keypad ButtonLED Display

1 and 300000001

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 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 IVCONCLUSION

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

BIBLIOGRAPHYTim Microcontroller. 2012. Microcontroller and Interface. Padang: PNP