SlideShare uma empresa Scribd logo
1 de 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:

Mais conteúdo relacionado

Mais procurados

Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現
Ron Liu
 
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
vrgokila
 
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
ilham ait hsain
 

Mais procurados (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
 

Destaque

Des Presentation
Des PresentationDes Presentation
Des Presentation
DavidTynan1
 
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-systems
PRADEEP
 

Destaque (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?
 

Semelhante a Keypad program

New text document
New text documentNew text document
New text document
Roja Patro
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd Year
Andrew Kozik
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
BlackD10
 
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
footstatus
 

Semelhante a 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)
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Último (20)

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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
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
 

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: