saving a number while pressing keypad

  Serial.print("\nEnter X ");
  char key = keypad.waitForKey();           
  Serial.println(key); // how to save the number from keypad ?

Your code currently only allows for the entry of a single digit number and it is a character representing a number rather than the number itself.

Step 1

  Serial.print("\nEnter X ");
  char key = keypad.waitForKey();           
  byte Xnumber = key - '0; //turn the character representing the single digit into a real number
  Serial.println(Xnumber);

I assume that you want to be able to accept numbers larger than a single digit. If so you need to either convert each character entered into a real number and combine it with the previous digits entered then, when a termination key, perhaps #, is pressed, use that number, or save each character as it is entered into an array and convert the array of characters into a number when the termination key is pressed. Both methods have been described in this thread.

nehasingh:
..... it has a medical application.

Oh my god, are you designing a medical application ?!

Then I have some code for you:

if( Patients.Start.Dying == TRUE ){

     Get( "Proffesional.Programmer" )

}
if (printingAMessage)
{
  use(aSpellChecker);
}

@mrExplore
I know I am a biologist and trying and started to enter a very new and different field...
I know that I dont know anything about programming..
Still....
atleast I am trying..
May be you will be new in my field...
Well.. thanks for the encouragement..

You're right nehasingh, my apologies.

@nehasingh: Please allow me a personal note, based on my experiences.

To program (and to learn how to program), you have to dirty your hands.
In general, there is no sacred code (while developing), you are working on a copy.
If you mess up, or drift in the wrong direction, you can always restart with the last 'best' version.

nehasingh:
with MINIMUM CHANGES in written CODE .

is pushing you in the wrong direction. IMHO

Changing the logic of a program may need (much) more than minimal changes,
but to knowingly sacrifice

  • stability
  • maintainability
  • ease of future changes
  • extendability
  • ...tends to be a bad idea and likes to bite you in the ... future (byte-wise sometimes ;)).

I admit that C++ looks like a concatenation of cryptic magic spells in the first place.
But if you want to learn and use Greek, there is no way around learning the Greek alphabet.

You get used to the language pretty fast if you use it.
No difference to spoken languages, without speaking,
it is harder to understand, and much harder to learn.

There is no need to understand or use every aspect of C++,
but the basic concepts are quite natural and logical.
Should be easy for an natural scientist,
everything is well defined and well documented.

Whandall:
To program (and to learn how to program), you have to dirty your hands.

Yes.

@nehasingh:
You have a very long way to go.
If you just want to use your Arduino to blink an LED, that is not hard to do. But you probably could not care less about blinking LEDs. You don't want to make toys. You want to make tools.
In order to make tools, especially the kind of tools you seem to want to make, you will have to do a lot of learning.
Unfortunately, it is not easy to find useful resources for people who want to learn to program an Arduino. What is there is generally very poorly organized, especially for a beginner, who might not even know where to start looking.

Can anyone here recommend a good place for this person to start?

odometer:
...
Unfortunately, it is not easy to find useful resources for people who want to learn to program an Arduino. What is there is generally very poorly organized, especially for a beginner, who might not even know where to start looking.

Can anyone here recommend a good place for this person to start?

I agree. I have had and I am still having the same issue. Not knowing where to look for the basic information about how something works. Be it arduino , actionscript as3, PIC programming, graphic design, cycling, or whatever. On forums and communities members assume a basic knowledge that beginners don't have yet.

That's why I posted earlier:

  • What are you trying to achieve here ?
  • What is the purpose of this system ?
  • What should the system do ?
  • What should the user do ?

nehasingh's code is exactly what I have seen in my own programming experience. Building upon something you do not really understand, being afraid to change or discard your approach and going back to the drawing board. Kill your darlings, it might sound scary but it's refreshing to start over.

...a good place for nehasingh start ... ?

I'd say Robin2's thread might help:

Planning and Implementing an Arduino Program

mrExplore:
Kill your darlings, it might sound scary but it's refreshing to start over.

I'd say it's more like pruning a tree. Keep the healthy, useful branches, and get rid of the rotten, useless ones.

For learning how to program and Arduino, the best (i.e. least bad) resource I know of is:
Adafruit's Arduino lessons
But I didn't say it was a good resource, I only said that it was the least bad.

Personally, I feel that Arduino is really not a good place to start learning to program. Maybe better to reverse-engineer some JavaScript or something. I know JavaScript sucks too, but at least you get immediate feedback and you don't have to worry about hooking up hardware. The immediate feedback is a huge help. (Note: JavaScript programs are not Arduino programs, and will not work on an Arduino.)

That reminds me: ideone.com lets you immediately (well, sort of immediately) compile and run programs in a lot of languages, including C++. Sometimes I use it to test functions I have written.

For Java-Script and Arduino type possibilities this looks interresting I think:

https://www.kickstarter.com/projects/gfw/espruino-javascript-for-things/description

Whandall:
For Java-Script and Arduino type possibilities this looks interresting I think:

https://www.kickstarter.com/projects/gfw/espruino-javascript-for-things/description

It's about @#!$% time!!