SlideShare a Scribd company logo
1 of 14
MINI – KEY 4x4




port 14 pin to 10 pin
HC11-CPU ET-EXP4
key switch connect MCS 51 and LCD




Shift =                            key switch



  =       “    ”      Shift

  =       “    ”      Shift

                        sin

  =       “   ”       Shift

                        cos
=    “         ”     Shift

                            tan

 =    “ ”           Shift

                            log

 =    “     ”        Shift

                            sqrt

 =    “     ”        Shift

                            epxp

 =    “     ”         Shift

                            pow 2

8=    “         ”     Shift

                            pow 3

9=    “     ”         Shift

                            absolute

+=                      “         ”

- =                     “     ”

*=                     “      ”

/ =                     “         ”
key switch
#include <at89c51xd2.h>

#include <stdlib.h>

#include <string.h>

#include <stdio.h>

#include <math.h>



sbit E = P0^2;

sbit RS = P0^0;

sbit a1 = P1^0; //row

sbit a2 = P1^1;

sbit a3 = P1^2;

sbit a4 = P1^3;

sbit b1 = P1^4;    //col

sbit b2 = P1^5;

sbit b3 = P1^6;

sbit b4 = P1^7;

char keyp()

{

char nkey = ' ';
a1 = 0; a2 = 1; a3 = 1; a4 = 1;

if(a1 == 0 && b1 == 0) nkey = '7';

else if(a1 == 0 && b2 == 0) nkey = '4';

else if(a1 == 0 && b3 == 0) nkey = '1';

else if(a1 == 0 && b4 == 0) nkey = 'c';



a1 = 1; a2 = 0; a3 = 1; a4 = 1;

if(a2 == 0 && b1 == 0) nkey = '8';

else if(a2 == 0 && b2 == 0) nkey = '5';

else if(a2 == 0 && b3 == 0) nkey = '2';

else if(a2 == 0 && b4 == 0) nkey = '0';



a1 = 1; a2 = 1; a3 = 0; a4 = 1;

if(a3 == 0 && b1 == 0) nkey = '9';

else if(a3 == 0 && b2 == 0) nkey = '6';

else if(a3 == 0 && b3 == 0) nkey = '3';

else if(a3 == 0 && b4 == 0) nkey = '=';



a1 = 1; a2 = 1; a3 = 1; a4 = 0;

if(a4 == 0 && b1 == 0) nkey = '/';

else if(a4 == 0 && b2 == 0) nkey = '*';

else if(a4 == 0 && b3 == 0) nkey = '-';

else if(a4 == 0 && b4 == 0) nkey = '+';

return nkey;

}

void delay(unsigned int count)

{

unsigned int i;

for(i=0;i<=count;i++);
}

void write_data(unsigned char c)

{

P0 = (c & 0xF0) | 0x01;

E = 1; delay(200);

E = 0; delay(200);

P0 = ((c << 4) & 0xF0) | 0x01;

E = 1; delay(200);

E = 0; delay(200);

}

void write_init(unsigned char i)

{

P0 = (i & 0xF0);

E = 1; delay(200);

E = 0; delay(200);



P0 = ((i<<4) & 0xF0) ;

E = 1; delay(200);

E = 0; delay(200);

}

void write_string(unsigned char *s)

{

unsigned short i, len;

len = strlen(s);



for(i = 0;i <= (len-1);i++)

{

write_data(s[i]);

}
}

float cal (float f, float l, unsigned char o)

{

float ans = 0;

if(o == '+') ans = f + l;

else if(o == '-') ans = f - l;

else if(o == '*') ans = f * l;

else if(o == '/') ans = f / l;

else if(o == 's') ans = sin(f);

else if(o == 'c') ans = cos(f);

else if(o == 't') ans = tan(f);

else if(o == 'l') ans = log(f);

else if(o == 'q') ans = sqrt(f);

else if(o == 'e') ans = exp(f);

else if(o == 'p') ans = pow(2,l);

else if(o == 'P') ans = pow(3,l);

else if(o == 'S') ans = abs(f);

return ans;

}



void main ()

{

unsigned char keypad;

unsigned char Fnum[7], Lnum[7], Ans[15];

float fnum = 0, lnum = 0, ans = 0;

unsigned char Oper = ' ';

unsigned short countdigit = 0;

unsigned short c, chkc = 1;

write_init(0x33);
write_init(0x32);

write_init(0x28);

write_init(0x0e);

write_init(0x01);

write_init(0x0c);

         while(1)

         {

         keypad = keyp();

         if(countdigit <= 5 && keypad >= '0' && keypad <= '9')

         {

         if(Oper == ' ') Fnum[countdigit] = keypad;

         else Lnum[countdigit] = keypad;

         write_data(keypad);

         countdigit++;

         }

else if(keypad == '+')

{

Oper = '+';

write_data('+');

countdigit = 0;

}

else if(keypad == '-')

{

Oper = '-';

write_data('-');

countdigit = 0;

}

else if(keypad == '*')

{
Oper = '*';

write_data('*');

countdigit = 0;

}

else if(keypad == '/')

{

Oper = '/';

write_data('/');

countdigit = 0;

}

else if(keypad == 'c')

{

chkc = 1;

while(chkc)

{

keypad = keyp();

if(keypad == '0')

{

write_init(0x01);

write_init(0x80);

countdigit = 0;

Oper = ' ';

for(c = 0;c <= 14;c++)

{

if(c<=7)

{

Fnum[c] = ' ';

Lnum[c] = ' ';

}
Ans[c] = ' ';

}

chkc = 0;

}

else if(keypad == '1')

{

Oper = 's';

write_string("sin ");

chkc = 0;

}

else if(keypad == '2')

{

Oper = 'c';

write_string("cos ");

chkc = 0;

}

else if(keypad == '3')

{

Oper = 't';

write_string("tan ");

chkc = 0;

}

else if(keypad == '4')

{

Oper = 'l';

write_string("log ");

chkc = 0;

}

else if(keypad == '5')
{

Oper = 'q';

write_string("sqrt ");

chkc = 0;

}

else if(keypad == '6')

{

Oper = 'e';

write_string("epxp ");

chkc = 0;

}

else if(keypad == '7')

{

Oper = 'p';

write_string("power 2 ");

chkc = 0;

}

else if(keypad == '8')

{

Oper = 'P';

write_string("power 3 ");

chkc = 0;

}

else if(keypad == '9')

{

Oper = 'S';

write_string("absolute ");

chkc = 0;

while(keypad !=' ')
{

keypad = keyp();

}

}

}

else if(keypad == '=' && Oper != ' ')

{

fnum = atof(Fnum);

lnum = atof(Lnum);

ans = cal(fnum,lnum,Oper);

sprintf(Ans,"%0.3f",ans);

write_init(0xC0);

write_data('=');

write_string(Ans);

}



while(keypad !=' ')

{

keypad = keyp();

}

}

}

More Related Content

What's hot (20)

งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
Lisp
LispLisp
Lisp
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
week-17x
week-17xweek-17x
week-17x
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
Code
CodeCode
Code
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
Chat code
Chat codeChat code
Chat code
 
Arduino code
Arduino codeArduino code
Arduino code
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
Vhdlbputspdas
VhdlbputspdasVhdlbputspdas
Vhdlbputspdas
 
Travel management
Travel managementTravel management
Travel management
 

Similar to Mini 4x4 keypad calculator

8051 C Assignments with all examples covered
8051 C Assignments with all examples covered8051 C Assignments with all examples covered
8051 C Assignments with all examples coveredAbdulMunaf52
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscationguest9006ab
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxpriestmanmable
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -Wataru Kani
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Contextlichtkind
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manualPrabhu D
 
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
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and PolynomialAroosa Rajput
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11nbb3i
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 

Similar to Mini 4x4 keypad calculator (20)

8051 C Assignments with all examples covered
8051 C Assignments with all examples covered8051 C Assignments with all examples covered
8051 C Assignments with all examples covered
 
Ch4
Ch4Ch4
Ch4
 
week-18x
week-18xweek-18x
week-18x
 
Vcs5
Vcs5Vcs5
Vcs5
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
Avl tree
Avl treeAvl tree
Avl tree
 
Struct examples
Struct examplesStruct examples
Struct examples
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
 
Os 2 cycle
Os 2 cycleOs 2 cycle
Os 2 cycle
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 

Recently uploaded

Creating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature SetCreating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature SetDenis Gagné
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth MarketingShawn Pang
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Lviv Startup Club
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Tina Ji
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurSuhani Kapoor
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 

Recently uploaded (20)

Creating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature SetCreating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
 
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 

Mini 4x4 keypad calculator

  • 1.
  • 2. MINI – KEY 4x4 port 14 pin to 10 pin
  • 4. key switch connect MCS 51 and LCD Shift = key switch = “ ” Shift = “ ” Shift sin = “ ” Shift cos
  • 5. = “ ” Shift tan = “ ” Shift log = “ ” Shift sqrt = “ ” Shift epxp = “ ” Shift pow 2 8= “ ” Shift pow 3 9= “ ” Shift absolute += “ ” - = “ ” *= “ ” / = “ ”
  • 6. key switch #include <at89c51xd2.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <math.h> sbit E = P0^2; sbit RS = P0^0; sbit a1 = P1^0; //row sbit a2 = P1^1; sbit a3 = P1^2; sbit a4 = P1^3; sbit b1 = P1^4; //col sbit b2 = P1^5; sbit b3 = P1^6; sbit b4 = P1^7; char keyp() { char nkey = ' ';
  • 7. a1 = 0; a2 = 1; a3 = 1; a4 = 1; if(a1 == 0 && b1 == 0) nkey = '7'; else if(a1 == 0 && b2 == 0) nkey = '4'; else if(a1 == 0 && b3 == 0) nkey = '1'; else if(a1 == 0 && b4 == 0) nkey = 'c'; a1 = 1; a2 = 0; a3 = 1; a4 = 1; if(a2 == 0 && b1 == 0) nkey = '8'; else if(a2 == 0 && b2 == 0) nkey = '5'; else if(a2 == 0 && b3 == 0) nkey = '2'; else if(a2 == 0 && b4 == 0) nkey = '0'; a1 = 1; a2 = 1; a3 = 0; a4 = 1; if(a3 == 0 && b1 == 0) nkey = '9'; else if(a3 == 0 && b2 == 0) nkey = '6'; else if(a3 == 0 && b3 == 0) nkey = '3'; else if(a3 == 0 && b4 == 0) nkey = '='; a1 = 1; a2 = 1; a3 = 1; a4 = 0; if(a4 == 0 && b1 == 0) nkey = '/'; else if(a4 == 0 && b2 == 0) nkey = '*'; else if(a4 == 0 && b3 == 0) nkey = '-'; else if(a4 == 0 && b4 == 0) nkey = '+'; return nkey; } void delay(unsigned int count) { unsigned int i; for(i=0;i<=count;i++);
  • 8. } void write_data(unsigned char c) { P0 = (c & 0xF0) | 0x01; E = 1; delay(200); E = 0; delay(200); P0 = ((c << 4) & 0xF0) | 0x01; E = 1; delay(200); E = 0; delay(200); } void write_init(unsigned char i) { P0 = (i & 0xF0); E = 1; delay(200); E = 0; delay(200); P0 = ((i<<4) & 0xF0) ; E = 1; delay(200); E = 0; delay(200); } void write_string(unsigned char *s) { unsigned short i, len; len = strlen(s); for(i = 0;i <= (len-1);i++) { write_data(s[i]); }
  • 9. } float cal (float f, float l, unsigned char o) { float ans = 0; if(o == '+') ans = f + l; else if(o == '-') ans = f - l; else if(o == '*') ans = f * l; else if(o == '/') ans = f / l; else if(o == 's') ans = sin(f); else if(o == 'c') ans = cos(f); else if(o == 't') ans = tan(f); else if(o == 'l') ans = log(f); else if(o == 'q') ans = sqrt(f); else if(o == 'e') ans = exp(f); else if(o == 'p') ans = pow(2,l); else if(o == 'P') ans = pow(3,l); else if(o == 'S') ans = abs(f); return ans; } void main () { unsigned char keypad; unsigned char Fnum[7], Lnum[7], Ans[15]; float fnum = 0, lnum = 0, ans = 0; unsigned char Oper = ' '; unsigned short countdigit = 0; unsigned short c, chkc = 1; write_init(0x33);
  • 10. write_init(0x32); write_init(0x28); write_init(0x0e); write_init(0x01); write_init(0x0c); while(1) { keypad = keyp(); if(countdigit <= 5 && keypad >= '0' && keypad <= '9') { if(Oper == ' ') Fnum[countdigit] = keypad; else Lnum[countdigit] = keypad; write_data(keypad); countdigit++; } else if(keypad == '+') { Oper = '+'; write_data('+'); countdigit = 0; } else if(keypad == '-') { Oper = '-'; write_data('-'); countdigit = 0; } else if(keypad == '*') {
  • 11. Oper = '*'; write_data('*'); countdigit = 0; } else if(keypad == '/') { Oper = '/'; write_data('/'); countdigit = 0; } else if(keypad == 'c') { chkc = 1; while(chkc) { keypad = keyp(); if(keypad == '0') { write_init(0x01); write_init(0x80); countdigit = 0; Oper = ' '; for(c = 0;c <= 14;c++) { if(c<=7) { Fnum[c] = ' '; Lnum[c] = ' '; }
  • 12. Ans[c] = ' '; } chkc = 0; } else if(keypad == '1') { Oper = 's'; write_string("sin "); chkc = 0; } else if(keypad == '2') { Oper = 'c'; write_string("cos "); chkc = 0; } else if(keypad == '3') { Oper = 't'; write_string("tan "); chkc = 0; } else if(keypad == '4') { Oper = 'l'; write_string("log "); chkc = 0; } else if(keypad == '5')
  • 13. { Oper = 'q'; write_string("sqrt "); chkc = 0; } else if(keypad == '6') { Oper = 'e'; write_string("epxp "); chkc = 0; } else if(keypad == '7') { Oper = 'p'; write_string("power 2 "); chkc = 0; } else if(keypad == '8') { Oper = 'P'; write_string("power 3 "); chkc = 0; } else if(keypad == '9') { Oper = 'S'; write_string("absolute "); chkc = 0; while(keypad !=' ')
  • 14. { keypad = keyp(); } } } else if(keypad == '=' && Oper != ' ') { fnum = atof(Fnum); lnum = atof(Lnum); ans = cal(fnum,lnum,Oper); sprintf(Ans,"%0.3f",ans); write_init(0xC0); write_data('='); write_string(Ans); } while(keypad !=' ') { keypad = keyp(); } } }