Devices & Components
LCD (Liquid Crystal Display
9V battery (generic)
Breadboard (generic)
LED (generic)
Resistor 330 ohm
USB that plugs to pc and arduino
Male/Female Jumper Wires
Arduino Mega 2560 R3 or Arduino Uno (both work great)
Rotary potentiometer (3 legs) 10k
Membrane Keypad
Project description
Code
Arduinolator Project Code
c_cpp
Just get a fresh new Arduino Code page, and delete everything. Then, paste this in.
1#include <Keypad.h> 2#include <LiquidCrystal.h> 3 4LiquidCrystal 5 lcd(0, 1, 2, 3, 4, 5); 6const byte ROWS = 4; 7const byte COLS = 4; 8 9char 10 keys [ROWS] [COLS] = { 11 {'1', '2', '3', '+'}, 12 {'4', '5', '6', '-'}, 13 14 {'7', '8', '9', '*'}, 15 {'C', '0', '=', '/'} 16}; 17byte rowPins[ROWS] = 18 {13,12,11,10}; 19byte colPins[COLS] = {9,8,7,6}; 20 21Keypad myKeypad = Keypad( 22 makeKeymap(keys), rowPins, colPins, ROWS, COLS ); 23 24boolean presentValue = 25 false; 26boolean next = false; 27boolean final = false; 28String num1, num2; 29int 30 answer; 31char op; 32 33void setup() 34{ 35 lcd.begin(16,2); //LCD starts 36 37 lcd.setCursor(0,0); 38 lcd.print("An Arduino"); //All this is text. You can 39 edit it 40 lcd.setCursor(0,1); 41 lcd.print("Calculator"); 42 delay(3000); 43 44 lcd.clear(); 45 lcd.setCursor(0,0); 46 lcd.print("The"); 47 lcd.setCursor(0,1); 48 49 lcd.print("Arduinolator!"); 50 delay(3000); 51 lcd.clear(); //LCD clears, 52 and you can begin using it. 53} 54 55void loop(){ 56 57 char key = myKeypad.getKey(); 58 59 60 if (key != NO_KEY && (key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0')) 61 62 { 63 if (presentValue != true) 64 { 65 num1 = num1 + key; 66 int 67 numLength = num1.length(); 68 lcd.setCursor(15 - numLength, 0); //to adjust 69 one whitespace for operator 70 lcd.print(num1); 71 } 72 else 73 74 { 75 num2 = num2 + key; 76 int numLength = num2.length(); 77 lcd.setCursor(15 78 - numLength, 1); 79 lcd.print(num2); 80 final = true; 81 } 82 } 83 84 85 else if (presentValue == false && key != NO_KEY && (key == '/' || key == '*' || 86 key == '-' || key == '+')) 87 { 88 if (presentValue == false) 89 { 90 91 presentValue = true; 92 op = key; 93 lcd.setCursor(15,0); 94 95 lcd.print(op); 96 } 97 } 98 99 else if (final == true && key != NO_KEY 100 && key == '='){ 101 if (op == '+'){ 102 answer = num1.toInt() + num2.toInt(); 103 104 } 105 else if (op == '-'){ 106 answer = num1.toInt() - num2.toInt(); 107 108 } 109 else if (op == '*'){ 110 answer = num1.toInt() * num2.toInt(); 111 112 } 113 else if (op == '/'){ 114 answer = num1.toInt() / num2.toInt(); 115 116 } 117 lcd.clear(); 118 lcd.setCursor(15,0); 119 lcd.autoscroll(); 120 121 lcd.print(answer); 122 lcd.noAutoscroll(); 123 } 124 else if (key != 125 NO_KEY && key == 'C'){ 126 lcd.clear(); 127 presentValue = false; 128 final 129 = false; 130 num1 = ""; 131 num2 = ""; 132 answer = 0; 133 op = 134 ' '; 135 } 136} 137
Arduinolator Project Code
c_cpp
Just get a fresh new Arduino Code page, and delete everything. Then, paste this in.
1#include <Keypad.h> 2#include <LiquidCrystal.h> 3 4LiquidCrystal lcd(0, 1, 2, 3, 4, 5); 5const byte ROWS = 4; 6const byte COLS = 4; 7 8char keys [ROWS] [COLS] = { 9 {'1', '2', '3', '+'}, 10 {'4', '5', '6', '-'}, 11 {'7', '8', '9', '*'}, 12 {'C', '0', '=', '/'} 13}; 14byte rowPins[ROWS] = {13,12,11,10}; 15byte colPins[COLS] = {9,8,7,6}; 16 17Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); 18 19boolean presentValue = false; 20boolean next = false; 21boolean final = false; 22String num1, num2; 23int answer; 24char op; 25 26void setup() 27{ 28 lcd.begin(16,2); //LCD starts 29 lcd.setCursor(0,0); 30 lcd.print("An Arduino"); //All this is text. You can edit it 31 lcd.setCursor(0,1); 32 lcd.print("Calculator"); 33 delay(3000); 34 lcd.clear(); 35 lcd.setCursor(0,0); 36 lcd.print("The"); 37 lcd.setCursor(0,1); 38 lcd.print("Arduinolator!"); 39 delay(3000); 40 lcd.clear(); //LCD clears, and you can begin using it. 41} 42 43void loop(){ 44 45 char key = myKeypad.getKey(); 46 47 if (key != NO_KEY && (key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0')) 48 { 49 if (presentValue != true) 50 { 51 num1 = num1 + key; 52 int numLength = num1.length(); 53 lcd.setCursor(15 - numLength, 0); //to adjust one whitespace for operator 54 lcd.print(num1); 55 } 56 else 57 { 58 num2 = num2 + key; 59 int numLength = num2.length(); 60 lcd.setCursor(15 - numLength, 1); 61 lcd.print(num2); 62 final = true; 63 } 64 } 65 66 else if (presentValue == false && key != NO_KEY && (key == '/' || key == '*' || key == '-' || key == '+')) 67 { 68 if (presentValue == false) 69 { 70 presentValue = true; 71 op = key; 72 lcd.setCursor(15,0); 73 lcd.print(op); 74 } 75 } 76 77 else if (final == true && key != NO_KEY && key == '='){ 78 if (op == '+'){ 79 answer = num1.toInt() + num2.toInt(); 80 } 81 else if (op == '-'){ 82 answer = num1.toInt() - num2.toInt(); 83 } 84 else if (op == '*'){ 85 answer = num1.toInt() * num2.toInt(); 86 } 87 else if (op == '/'){ 88 answer = num1.toInt() / num2.toInt(); 89 } 90 lcd.clear(); 91 lcd.setCursor(15,0); 92 lcd.autoscroll(); 93 lcd.print(answer); 94 lcd.noAutoscroll(); 95 } 96 else if (key != NO_KEY && key == 'C'){ 97 lcd.clear(); 98 presentValue = false; 99 final = false; 100 num1 = ""; 101 num2 = ""; 102 answer = 0; 103 op = ' '; 104 } 105} 106
Downloadable files
Schematics
Schematics were created by me, using power point. But I uploaded an image for anyone wanting to do it, who didn't have power point.
Schematics

Comments
Only logged in users can leave comments