How to total using keypad?

Hi All,

How to total using keypad(For example if i press from keypad 11 it should show the total)?.

Regards
JR

Hi seejr:

Are you asking if you can make a calculator with an Arduino?

Hi LarryD,

Actually not for calculator.Below is my code with this what i want to achieve is when i press from keypad 1 it should show exact value from array.I am getting values that is not equal to what value i entered from keypad.Can you or can some body please check the code and suggest how to get the exact out put.

Note:Out put when i press the numbers

If i press 1 i get oil and if i press 2 i am getting HairC. It is going increment in a wrong way.

Thanks & Regards
JR

#include <LiquidCrystal.h>
#include "Keypad.h"
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// keypad type definition
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char customKey;
int total = 0;
int sum;
#define ledPin 13
char keys[ROWS][COLS] =
{ {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2, 3, 11, 12}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A2, A3, A4, A5}; // connect to the column pinouts of the keypad
int count = 0;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//===========================================================================
void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();
}
void loop() {
  char key = keypad.getKey();

  if (key != NO_KEY)
  {
    lcd.print(key);
    count++;
    lcd.setCursor(0, 12);
    if (count == 17)
    {
      lcd.clear();
      count = 0;
    }
    if (key == '*')
      guru1();

    digitalWrite(ledPin, LOW);   // sets the LED on
    if (key == '#')
      lcd.clear();
    digitalWrite(ledPin, HIGH);    // sets the LED of
  }

}
void guru1() {
 z]09-+  int i;
    static char *Stt[100] = {"Rice", "Oil", "Masal", "HCare", "HairC", "Baby", "Pickle", "Oral Care", "Dry Fruits", "Noodles", "Midha"};
  static int prices[100] = {0, 52, 70, 15, 62, 75, 175, 58, 44, 17, 30, 35};
  for (i = 0; i <count; i++) {
    lcd.setCursor(0, 0);
    lcd.println(Stt[i]);
    lcd.setCursor(10, 0);
    lcd.println(prices[i]);
    }
}

Any key increments the count, but in pressing the * key you will display all the items one after the other so quickly that you will only ever see the last one.

It is not clear what you want this code to do.

What is that mess before the int i in the guru1 function?

Grumpy_Mike:
Any key increments the count, but in pressing the * key you will display all the items one after the other so quickly that you will only ever see the last one.

It is not clear what you want this code to do.

What is that mess before the int i in the guru1 function?

Hi Grumpy_Mike,

What this code does is if i press 1 from keypad and it has has fetch the array values from Stt & Price(for example oil and 52 will be displayed).Like number search.But the problem is it is not showing exact value.
Any idea how to get exact value.I am using Arduino Uno +LCD Shield + Number Keypad.

It was my typing mistake before int i,it is int i only.

What this code does is .......

No that is what you want it to do maybe but that is not what it does.

Grumpy_Mike:
No that is what you want it to do maybe but that is not what it does.

Yes.Any Solution for this?.

Yes write the code that does what you want to do, not what it actually does.
I think your problem is that you are not clear what you want it to do. I certainly am not clear.