This document describes the design of a basic standard calculator using an ATMega16 microcontroller. The calculator can perform basic arithmetic operations of addition, subtraction, multiplication and division on two operands using a 4x4 keypad for input and a 2x16 LCD for output display. The microcontroller is programmed to read keypad input, perform calculations and display results on the LCD. It provides code examples for interfacing the keypad and LCD with the microcontroller and implementing the calculator functionality.
1. Basic Standard Calculator
(Using ATMega16 Microcontroller)
Aim of this project is to design a calculating device capable of
performing basic calculations (add, subtract, multiply, divide) on two
operands.
Project overview
Basic Standard Calculator
2. Hardware components required
1. ATMega 16 microcontroller
2. Basic calculator keypad
3. 2x16 LCD
Keypad and LCD are connected with microcontroller to make an easy man-machine
interface to make the calculator capable of performing the desired
function.
ATMega16 microcontroller: This is the brain of system which is
programmed to take input from user through keypad, perform the
desired operation and then display the result on the provided 2x16 LCD.
Basic calculator keypad: This is a 4x4 (having 4 rows and 4 columns)
keypad which is interfaced with microcontroller with its each key
assigned a specific no. or operator defined in the program.
2x16 LCD: this is the liquid crystal display module capable of
displaying 32 characters in two rows (16 in each row). Microcontroller
displays characters on it while taking inputs from user and to display the
result to user.
3. Interfacing keypad with microcontroller
Keyboard Connections to PORTS
With matrix keypads 16 keys can function with 8 pins (4 rows and 4 columns)
of microcontroller’s either same or different ports as convenient.
10. Calculator
The functioning of calculator s as follows:
i. Enter first operand
ii. Enter operator
iii. Enter second operand
iv. Press result key
Main program:
#include<avr/io.h>
#include<util/delay.h>
#include"4bitlcd.h"
#include"keypad.h"
#define key_port PORTA
#define key_ddr DDRA
#define key_pin PINA
void lcd_cmd(unsigned char cmd);
void lcd_data(unsigned char data);
void ini_lcd(void);
void main()
{
unsigned char ch=0,op=0;
long o1=0,o2=0,o3=0,ch1=0;
PORTB=0XFF;
DDRB=0xff;
_delay_ms(5);
ini_lcd();
while(1)
{