Arduino Calculator

The full build is on my youtube channel please subscribe to my channel to suport my robotics

Other Articals

Microbit Robots and Tutorials

My name is Ben I am 13 years old i love designing and making robots i also like coding. I make robots with Microbits, Arduinos and rasberry pi's


Youtube Channel

Subscribe to my youtube channel to suport my robotics journey

Nature

Microbit Guitar

Date:November 15, 2025

I found this guitar when I was tidying my loft, and I was going to throw it away when I had a fantastic idea. The idea was to upcycle the guitar by removing the strings and adding a microbit.


picture of microbit guitar

How was it made?

The arduino calculator was made by make making a 12 by 16 cm frame. then i covered the frame with mounting board and cut out some holes for a lcd screen and keypad. I then bloted the lcd screen to the mounting board and stuck the keypad to the mounting board by peeling back the sticker at the back.I then installled an arduino and conected all of the jumper wires to the arduino.

Materials list

Name Price Link
Keypad £4.49 Click Here
LCD screen £7.95 Click Here
Arduino Uno Board £12.10 Click Here
Jumper wires £4.58 Click here
Power cable for Arduino £3.99 Click here
9v battery £6.29 Click here

Circuit plan

picture of circuit plan

Hardware Tutorial


I got the idea when I was putting up my Christmas tree. I thought what if I made a smaller tree with LED’s.


  1. first i needed to made a wooden frame i cut 4 pices of wood 2 of them 12 cm and the other two 16cm.

  2. Then i sanded all of the wood.

  3. Next i drilled some holes and countersunk them so that the screws are flush to the wood. i then screwed some 2cm screws into each hole

  4. Then i traced around the frame onto some mounting board on each side. on the front i also cut out a hole for the lcd and keypad

  5. Then i screwed all of the sides on to the wooden frame with some 1cm scews and a 1.5 mm drill bit

  6. The i installed the lcd screen by using 4 bolts.

  7. I then installed the keypad by peeling of the sticky back and sticking it on to the mounting board

  8. I then pugged all of the jumper wires into the arduino and using the wiring diagram above


Software Tutorial

arduino calucator full code - click here

Now we have done the hardware tutorual we now need some code to make it work copy this code into arduino ide and upload it to your arduino you will also need to install the keypad and lcd library

Ardino calculator code
        
#include 
#include 

const byte ROWS = 4;  // Number of rows on the keypad
const byte COLS = 4;  // Number of columns on the keypad

char keys[ROWS][COLS] = {
  { '1', '2', '3', '+' },
  { '4', '5', '6', '-' },
  { '7', '8', '9', '*' },
  { 'C', '0', '=', '/' }
};

byte rowPins[ROWS] = { 9, 8, 7, 6 };  // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins
byte colPins[COLS] = { 5, 4, 3, 2 };  // Connect keypad COL0, COL1, COL2 and COL3 to these Arduino pins

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

LiquidCrystal_I2C lcd(0x27, 16, 2);

String input = "";
char* expressionToParse;
bool cleared = true;

void setup() {
  lcd.init();
  lcd.backlight();
}

void loop() {
  char key = keypad.getKey();

  if (key != NO_KEY) {

    if (!cleared) {
      clearDisplay();
    }

    if (key == '=') {
      calculateResult();
    } else if (key == 'C') {
      clearDisplay();
    } else {
      lcd.print(key);
      input = input + key;
    }
  }
}

  void calculateResult() {
    lcd.setCursor(0, 1);
    lcd.print("Result:");

    input.trim();

    expressionToParse = input.c_str();
    lcd.setCursor(8, 1);
    float result = expression();
    if(isinf(result) == 0 && isnan(result)==0){
      lcd.print(result);
    }else{
      lcd.print("Invalid");
    }
    cleared = false;
  }

  void clearDisplay() {
    lcd.clear();
    input = "";
    cleared = true;
  }

  char peek() {
    return *expressionToParse;
  }

  char get() {
    return *expressionToParse++;
  }

  float number() {
    float result = get() - '0';
    while (peek() >= '0' && peek() <= '9') {
      result = 10 * result + get() - '0';
    }
    return result;
  }

  float factor() {
    if (peek() >= '0' && peek() <= '9')
      return number();
    else if (peek() == '(') {
      get();  // '('
      float result = expression();
      get();  // ')'
      return result;
    } else if (peek() == '-') {
      get();
      return -factor();
    }
    return 0;  // error
  }

  float term() {
    float result = factor();
    while (peek() == '*' || peek() == '/')
      if (get() == '*')
        result *= factor();
      else
        result /= factor();
    return result;
  }

  float expression() {
    float result = term();
    while (peek() == '+' || peek() == '-')
      if (get() == '+')
        result += term();
      else
        result -= term();
    return result;
  }

}

Testing and observation

  1. The Lcd backlight worked well even though some of it was covered
  2. The keypad worked well and it stuck down well with the stick back on the back of it
  3. it can proform calculations easy and eficiantly

Challanges

  1. fittng a back because there was no room for a back
  2. programming it because this is my first time using a lcd screen and keypad

Future Changes

  1. make the frame a bit thicker to add a back
  2. have a smaller arduino to make it thinner
  3. add some more buttons on the top for reset and other tings so i can do decimal points on the calculator

Conclusion

The calculator works well and performs complex calculations

© copyright travismewis.co.uk