SlideShare une entreprise Scribd logo
1  sur  4
#include<reg51.h>
#define port P1;
#define dataport P2;
#define key P0 ;
void lcd_data_str(unsigned char *str);
void lcd(unsigned char str[10]);
void lcd_data(unsigned char item1);
void display(int a);
void lcd_cmd(unsigned char item);
void chek_col1();
void chek_col2();
void chek_col3();
void chek_col4();
void delay(unsigned int m);
sbit rs=port^1;
sbit rw=port^2;
sbit en=port^3;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;
sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit col4=key^7;
//Main program

void main()
{
lcd_cmd(0x01);
lcd_data_str("welcome");
col1=col2=col3=col4=1;
while(1)
{
row1=row2=row3=row4=0;
if(col1==0)
chek_col1();
else if (col2==0)
chek_col2();
else if(col3==0)
chek_col3();
else
chek_col4();
}
}

//Function to decide the key pressed in col1
void chek_col1()
{
row1=row2=row3=row4=1;
row1=0;
if(col1==0)
display(1);
row1=1;
row2=0;
if(col1==0)
display(5);
row2=1;
row3=0;
if(col1==0)
display(9);
row3=1;
row4=0;
if(col1==0)
display(13);
row4=1;
}




//Function to decide the key pressed in col2
void chek_col2()
{
row1=row2=row3=row4=1;
row1=0;
if(col2==0)
display(2);
row1=1;
row2=0;
if(col2==0)
display(6);
row2=1;
row3=0;
if(col2==0)
display(10);
row3=1;
row4=0;
if(col2==0)
display(14);
row4=1;
}

//Function to decide the key pressed in col3

void chek_col3()
{
row1=row2=row3=row4=1;
row1=0;
if(col3==0)
display(3);
row1=1;
row2=0;
if(col3==0)
display(7);
row2=1;
row3=0;
if(col3==0)
display(11);
row3=1;
row4=0;
if(col3==0)
display(15);
row4=1;

}

//Function to decide the key pressed in col4
void chek_col4()
{
row1=row2=row3=row4=1;
row1=0;
if(col4==0)
display(4);
row1=1;
row2=0;
if(col4==0)
display(8);
row2=1;
row3=0;
if(col4==0)
display(12);
row3=1;
row4=0;
if(col4==0)
display(16);
row4=1;
}

//Function to send Command to LCD
void lcd_cmd(unsigned char item)
{
dataport=item;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
return;
}
//Function to send Data to LCD
void lcd_data(unsigned char item1)
{
dataport=item1;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
return;
}



// Function to send string to lcd_data
void lcd_data_str(unsigned char *str)
{
int i=0;
while(str[i]!='0')
{
lcd_data(str[i]);
i++;
delay(10);
}
return;
}

//Function to initialize the LCD
void lcd(unsigned char str[10])
{
lcd_cmd(0x38);
lcd_cmd(0x0E);
lcd_cmd(0x01);
lcd_cmd(0x82);
lcd_data_str(str);
}

//Function to send the string to be displayed

void display(int a)
{
switch(a)
{
case 1:lcd("One :1");
break;
case 2:lcd("Two :2");
break;
case 3:lcd("Three :3");
break;
case 4:lcd("Four :4");
break;
case 5:lcd("Five :5");
break;
case 6:lcd("Six :6");
break;
case 7:lcd("Seven :7");
break;
case 8:lcd("Eight :8");
break;
case 9:lcd("Nine :9");
break;
case 10:lcd("Ten :10");
break;
case 11:lcd("Eleven :11");
break;
case 12:lcd("Twelve :12");
break;
case 13:lcd("Thirteen :13");
break;
case 14:lcd("Fourteen :14");
break;
case 15:lcd("Fifteen :15");
break;
case 16:lcd("sixteen :16");
break;
default:lcd("others");
break;
}
}

//Delay Function
void delay(unsigned int m )
{
int i,j;
for(i=0;i<m;i++)
for(j=0;j<1275;j++);
}

Result:

Contenu connexe

Tendances

Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Ron Liu
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console InterfaceDavid Young
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESkarthik kadava
 
Unit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programmingUnit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programmingvrgokila
 
Controlling Motors for Robot
Controlling Motors for RobotControlling Motors for Robot
Controlling Motors for RobotVarad Manglekar
 
Verilog full adder in dataflow & gate level modelling style.
Verilog full adder in dataflow  & gate level modelling style.Verilog full adder in dataflow  & gate level modelling style.
Verilog full adder in dataflow & gate level modelling style.Omkar Rane
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical fileArchita Misra
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical FileSoumya Behera
 
Practical file
Practical filePractical file
Practical filerajeevkr35
 
Programme en C: Additionneur complet 4 bits ac4
Programme en C: Additionneur  complet 4 bits ac4Programme en C: Additionneur  complet 4 bits ac4
Programme en C: Additionneur complet 4 bits ac4ilham ait hsain
 

Tendances (20)

Vcs15
Vcs15Vcs15
Vcs15
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
گزارش کار
گزارش کارگزارش کار
گزارش کار
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console Interface
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
 
Unit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programmingUnit 1 ocs752 introduction to c programming
Unit 1 ocs752 introduction to c programming
 
VHDL CODE
VHDL CODE VHDL CODE
VHDL CODE
 
Controlling Motors for Robot
Controlling Motors for RobotControlling Motors for Robot
Controlling Motors for Robot
 
Vhdl
VhdlVhdl
Vhdl
 
MFC Rect2
MFC Rect2MFC Rect2
MFC Rect2
 
Verilog full adder in dataflow & gate level modelling style.
Verilog full adder in dataflow  & gate level modelling style.Verilog full adder in dataflow  & gate level modelling style.
Verilog full adder in dataflow & gate level modelling style.
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
 
Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
C test
C testC test
C test
 
REPORT
REPORTREPORT
REPORT
 
Practical file
Practical filePractical file
Practical file
 
Programme en C: Additionneur complet 4 bits ac4
Programme en C: Additionneur  complet 4 bits ac4Programme en C: Additionneur  complet 4 bits ac4
Programme en C: Additionneur complet 4 bits ac4
 

En vedette

Des Presentation
Des PresentationDes Presentation
Des PresentationDavidTynan1
 
Interface gsm with 8051 microcontroller (at89 c51)
Interface gsm with 8051 microcontroller (at89 c51)Interface gsm with 8051 microcontroller (at89 c51)
Interface gsm with 8051 microcontroller (at89 c51)mdkousik
 
13986149 c-pgming-for-embedded-systems
13986149 c-pgming-for-embedded-systems13986149 c-pgming-for-embedded-systems
13986149 c-pgming-for-embedded-systemsPRADEEP
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

En vedette (8)

Des Presentation
Des PresentationDes Presentation
Des Presentation
 
Interface gsm with 8051 microcontroller (at89 c51)
Interface gsm with 8051 microcontroller (at89 c51)Interface gsm with 8051 microcontroller (at89 c51)
Interface gsm with 8051 microcontroller (at89 c51)
 
13986149 c-pgming-for-embedded-systems
13986149 c-pgming-for-embedded-systems13986149 c-pgming-for-embedded-systems
13986149 c-pgming-for-embedded-systems
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Similaire à Keypad program

New text document
New text documentNew text document
New text documentRoja Patro
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxSANTIAGO PABLO ALBERTO
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd YearAndrew Kozik
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuenteBlackD10
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Shinya Takamaeda-Y
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 CardOmar Sanchez
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programsbabak danyal
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdffootstatus
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignmentbabak danyal
 
Atmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileAtmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileABHISHEK MAURYA
 
2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdfVNEX
 

Similaire à Keypad program (20)

New text document
New text documentNew text document
New text document
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd Year
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programs
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
 
Atmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileAtmega lcd programing_with_header_file
Atmega lcd programing_with_header_file
 
Fpga creating counter with external clock
Fpga   creating counter with external clockFpga   creating counter with external clock
Fpga creating counter with external clock
 
VHDL Programs
VHDL ProgramsVHDL Programs
VHDL Programs
 
2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf
 
Tdm to vo ip 2
Tdm to vo ip 2Tdm to vo ip 2
Tdm to vo ip 2
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 

Dernier

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Dernier (20)

Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Keypad program

  • 1. #include<reg51.h> #define port P1; #define dataport P2; #define key P0 ; void lcd_data_str(unsigned char *str); void lcd(unsigned char str[10]); void lcd_data(unsigned char item1); void display(int a); void lcd_cmd(unsigned char item); void chek_col1(); void chek_col2(); void chek_col3(); void chek_col4(); void delay(unsigned int m); sbit rs=port^1; sbit rw=port^2; sbit en=port^3; sbit row1=key^0; sbit row2=key^1; sbit row3=key^2; sbit row4=key^3; sbit col1=key^4; sbit col2=key^5; sbit col3=key^6; sbit col4=key^7; //Main program void main() { lcd_cmd(0x01); lcd_data_str("welcome"); col1=col2=col3=col4=1; while(1) { row1=row2=row3=row4=0; if(col1==0) chek_col1(); else if (col2==0) chek_col2(); else if(col3==0) chek_col3(); else chek_col4(); } } //Function to decide the key pressed in col1 void chek_col1() { row1=row2=row3=row4=1; row1=0; if(col1==0) display(1); row1=1; row2=0; if(col1==0) display(5); row2=1; row3=0; if(col1==0) display(9); row3=1; row4=0; if(col1==0)
  • 2. display(13); row4=1; } //Function to decide the key pressed in col2 void chek_col2() { row1=row2=row3=row4=1; row1=0; if(col2==0) display(2); row1=1; row2=0; if(col2==0) display(6); row2=1; row3=0; if(col2==0) display(10); row3=1; row4=0; if(col2==0) display(14); row4=1; } //Function to decide the key pressed in col3 void chek_col3() { row1=row2=row3=row4=1; row1=0; if(col3==0) display(3); row1=1; row2=0; if(col3==0) display(7); row2=1; row3=0; if(col3==0) display(11); row3=1; row4=0; if(col3==0) display(15); row4=1; } //Function to decide the key pressed in col4 void chek_col4() { row1=row2=row3=row4=1; row1=0; if(col4==0) display(4); row1=1; row2=0; if(col4==0) display(8);
  • 3. row2=1; row3=0; if(col4==0) display(12); row3=1; row4=0; if(col4==0) display(16); row4=1; } //Function to send Command to LCD void lcd_cmd(unsigned char item) { dataport=item; rs=0; rw=0; en=1; delay(1); en=0; return; } //Function to send Data to LCD void lcd_data(unsigned char item1) { dataport=item1; rs=1; rw=0; en=1; delay(1); en=0; return; } // Function to send string to lcd_data void lcd_data_str(unsigned char *str) { int i=0; while(str[i]!='0') { lcd_data(str[i]); i++; delay(10); } return; } //Function to initialize the LCD void lcd(unsigned char str[10]) { lcd_cmd(0x38); lcd_cmd(0x0E); lcd_cmd(0x01); lcd_cmd(0x82); lcd_data_str(str); } //Function to send the string to be displayed void display(int a) { switch(a)
  • 4. { case 1:lcd("One :1"); break; case 2:lcd("Two :2"); break; case 3:lcd("Three :3"); break; case 4:lcd("Four :4"); break; case 5:lcd("Five :5"); break; case 6:lcd("Six :6"); break; case 7:lcd("Seven :7"); break; case 8:lcd("Eight :8"); break; case 9:lcd("Nine :9"); break; case 10:lcd("Ten :10"); break; case 11:lcd("Eleven :11"); break; case 12:lcd("Twelve :12"); break; case 13:lcd("Thirteen :13"); break; case 14:lcd("Fourteen :14"); break; case 15:lcd("Fifteen :15"); break; case 16:lcd("sixteen :16"); break; default:lcd("others"); break; } } //Delay Function void delay(unsigned int m ) { int i,j; for(i=0;i<m;i++) for(j=0;j<1275;j++); } Result: