Calculator using PIC micro-controller

Published Sep 05, 2018
 4 hours to build
 Beginner

Build a Calculator using PIC18f4550 which can perform float addition, subtraction, multiplication and division.

display image

Components Used

LCD 16x2 Display Module
LCD16x2 has two lines with 16 character in each line. LCD16x2 is generally used for printing values and string in embedded application.
1
PIC18f4550
PIC18f4550
1
4x4 Keypad Module
Keypad is an input device which is generally used in applications such as calculator, ATM machines, computer etc.
1
Description

Calculator

Calculator is an application which is used in daily use for calculation like Addition, Subtraction, Multiplication and Division.

So here I built my first project Calculator using PIC micro-controller which is used for calculation.

For this application, PIC18F4550 Micro-controller along with 4x4 Matrix Keypad and 16x2 LCD are used.

In this Calculator, I calculated addition, subtraction, multiplication and division.

This calculator can calculate signed value range from -2,147,483,648 to 2,147,483,648.

Now to design a calculator one should know about 4x4 Keypad interfacing with PIC microcontroller and 16x2 LCD interfacing with PIC microcontroller.

Interfacing Diagram

Connection details

Here 16x2 LCD is connected to the PIC18F4550 in 4-bit mode to PORTB.

RS = PB0 (PORTB 0)

EN = PB1 (PORTB 1)

RW = GND for write operation.

PORTB (B4-B7) = LCD Data line.

4x4 Matrix keypad is connected to PORTD where lower port bits (D0-D3) connected to ROW and higher port bits (D4-D7) connected to column.

Algorithm

1.       Initialize LCD.

2.       Wait for key pressed and find key.

3.       If it is digit, then store it in array of 1st no.

4.       Then key pressed is ‘operator’ and store it in variable.

5.       Enter 2nd digit for operation and store it in array of 2nd no.

6.       Now convert 1st and 2nd no. string (array of char) to long integer.

7.       Do operation as per stored operator variable when “=” key is detected

8.       And display calculated result on LCD.

Video

Codes
Comments
Ad