Introduction: Arithmetic Mean Calculator

About: 17 developer delhi
  • This is a maths prototype model with takes in values from the user and uses it to calculate mean.
  • This project can be used for tons of different purposes such as calculating average marks, mean of physical quantities.
  • The need to calculate mean can be different for different people. This makes the project open to everyone.

Step 1: Mathematic Principle Involve

  • M = sum of the terms / number of terms

Step 2: Description

Materials Required

  • Arduino Uno
  • LCD display (16*2)
  • Keypad matrix (4*4)
  • Buzzer
  • Bread board
  • Jumper wire

Construction

  • Connect the lcd display to digital pin of Arduino( Rs = 2, En = 3, D4 = 4, D5= 5, D6 = 6,D7 = 7).
  • Keypad's first 4 pins are row pins then column.
  • Connect keypad matrix pin to Arduino pin (1 = 12, 2 = 11, 3 = 10, 4 = 9, 5 = A0, 6 = A1, 7 = A2, 8 = A3)
  • Connect buzzer to digital pin 13 of Arduino.
  • Open Arduino idle and write the code.

Working

  • When the user presses a botton on keypad the change in voltage is noted by the MCU. Then it checks for the character assigned to it.
  • In this project we are using lcd display at 4 bit mode. The value entered by the user will be displayed on the lcd.
  • The buzzer connected to pin 13 of Arduino will buzz every time you press a button.
  • All the functions being performed are coded in the MCU. This includes the functionality to calculate mean.

Reference

While I was working on a project based on parralex method. I felt the need to bult a device that could calculate mean of large numbers in seconds.

Step 3: Code

#include <Keypad.h>const byte ROWS = 4; /* four rows */const byte COLS = 4; /* four columns *//* define the symbols on the buttons of the keypads */char hexaKeys[ROWS][COLS] = {  {'1','2','3','A'},  {'4','5','6','B'},  {'7','8','9','C'},  {'*','0','#','D'}};byte rowPins[ROWS] = {12, 11, 10, 9}; /* connect to the row pinouts of the keypad */byte colPins[COLS] = {A0, A1, A2, A3}; Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);#include <LiquidCrystal.h>LiquidCrystal lcd(2, 3, 4, 5, 6, 7);int beep = 13;String name;long int a = 0;int count = 1;long int arr[0];long int x = 0;double x_0;int i = 0;long int arr_mean[0];long int y = 0;long big, small;double divide;void setup() {    pinMode(beep, OUTPUT);    lcd.begin(16, 2);     Serial.begin(9600);  Serial.print("Working !");  lcd.clear();  lcd.setCursor(0,0);  lcd.print("MEAN CALCULATOR");  lcd.setCursor(0,1);  lcd.print("Ishaan 11-F");  digitalWrite(beep,HIGH);  delay(50);  digitalWrite(beep,LOW);  delay(2000);  lcd.clear();      }void loop() {     while(true){    lcd.setCursor(0,0);    lcd.print("Enter a number:");        char customkey = customKeypad.getKey();          if (customkey){      char val = customkey;              if(val != 'A' & val != 'B' & val != 'C' & val != 'D' & val != '*'){        if(val == '#')        {                          long int data = a;                    lcd.clear();                  arr[count] = {data};          x = x + arr[count];                        count += 1;          Serial.println(arr[count-1]);                    digitalWrite(beep,HIGH);          delay(50);          digitalWrite(beep,LOW);                    lcd.setCursor(0,0);          lcd.print("You Entered:- ");          lcd.setCursor(0,1);          lcd.print(data);                    digitalWrite(beep,HIGH);          delay(50);          digitalWrite(beep,LOW);                        delay(1000);          lcd.clear();          a = 0;        }                       else        {          digitalWrite(beep,HIGH);          delay(50);          digitalWrite(beep,LOW);                    a = a * 10;          a += (val- 48);                    lcd.setCursor(0,1);          lcd.print(a);                }      }            if(val == '*')      {                    double divide = count - 1;        double x_0 = x/divide;                lcd.clear();        lcd.setCursor(0,0);        lcd.print("Mean = ");        lcd.print(x_0);        delay(5000);          lcd.clear();             break;                    }    }         }}