Arduino Calculator - Vathsav
Arduino Calculator - Vathsav
Arduino Calculator - Vathsav
Arduino Calculator
Saturday 15, November '14 Arduino (../categories/arduino)
This is a calculator that can perform basic arithmetic operations. This was done using an Arduino Uno, a
16x2 LCD display and a 4x4 dot matrix keypad.
The keypad library doesn't come with the Arduino IDE. You're gonna have to download
(http://playground.arduino.cc/Code/Keypad) and import it for you to be able to use the matrix keypad.
Place the downloaded file into the /libraries folder.
(../img/arduino_calculator/sketch.png)
This sketch was made using Fritzing (http://fritzing.org/), an awesome open source tool for bulding
prototypes.
http://www.vathsav.com/post/arduino_calculator.html 1/5
8/31/2017 Arduino Calculator | Vathsav
/*
Layout of 4x4 Dot Matrix Keyboard:
^
C R >
o o o o
o o o o
o o o o
o o o o
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
*-------------------------------*
| 2 +| <--- Memory here
| | <--- Cursor set here
*-------------------------------*
*/
The code is pretty simple. You're gonna have to define the keypad's layout in a 2 dimensional array, and
assign it to an instance of the Keypad class.
In the setup function, we shall initialize the LCD and print a hello message for two and a half seconds.
//variables declaration
boolean valOnePresent = false;
boolean next = false;
boolean final = false;
String num1, num2;
int ans;
char op;
void setup(){
lcd.begin(16,2);
lcd.setCursor(2,0);
lcd.print("Hello World!");
delay(2500);
lcd.clear(); //clears the LCD screen and positions the cursor in the upper-left corner.
}
http://www.vathsav.com/post/arduino_calculator.html 2/5
8/31/2017 Arduino Calculator | Vathsav
void loop(){
char key = myKeypad.getKey();
SHARE
Share Share
Sort by Best
Recommend ⤤ Share
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
Check your connections to the LCD. You see weird symbols if the jumpers are loosely connected.
△ ▽ • Reply • Share ›
Hey!
Yes, I used a 10k trimmer and a 10k ohm resistor.
△ ▽ • Reply • Share ›
Cool! :)
△ ▽ • Reply • Share ›
Hey Chinn,
You seem to have forgotten to include the LCD and Keypad libraries.
#include <liquidcrystal.h>
#include <keypad.h>
△ ▽ • Reply • Share ›
The pins on the breadboard are connected vertically. The right lead of the resistor is connected to 5V and the left lead is
connected to the LCD's backlight.
△ ▽ • Reply • Share ›
You're right, it slipped my mind. There were 2 wires connected to the backlight. I've updated the sketch now.
Thanks man!
△ ▽ • Reply • Share ›
AvatarVathsav Harikrishnan — Sure :)The pin configuration on your RFID AvatarVathsav Harikrishnan — I'm glad it is :)
module might be different. Make sure you get the connections …
AvatarPhil — Awesome!! AvatarVathsav Harikrishnan — I'm sorry for your loss, Lukasz. I cannot
imagine how it must have been. Things just don't make sense
sometimes and …
ABOUT
SUBSCRIBE
Email Address
SUBSCRIBE
CATEGORIES
Android (../categories/android)
Arduino (../categories/arduino)
Particle Core (../categories/particle_core)
Processing (../categories/processing)
Rants (../categories/rants)
http://www.vathsav.com/post/arduino_calculator.html 5/5