sorrry, im kinda new to this, will do the thing with putting in inputs to see the output, also how do you print the input on a serial pin?
EDIT: have tested it and all the inputs work, just seems that the program isnt using them correctly in the cases
Toby_Resnick:
... how do you print the input on a serial pin?
Not serial pin. Serial terminal. Use Serial.print() and Serial.println();
EDIT: have tested it and all the inputs work, just seems that the program isn't using them correctly in the cases
I guess that means that you figured out how to print to the serial terminal.
I think that means that you get the keys that you expect from the keypad. I think that means that you don't get valid data after that. I can't tell anything about what you actually do get.
I'll recommend that you read, "How to use this forum - please read." You can find it here - http://forum.arduino.cc/index.php/topic,148850.0.html. In particular, I'll suggest #11, "Tips for getting the most out of your post," and in more particular, these three items in that list:
- Describe what you expected to happen, and what actually happened. Not just "it doesn't work".
- ossible, describe what you are really trying to do, not what you think might work. For example "I am trying to turn on an aquarium heater and pump at the same time", not "how do I break out of an interrupt?".
- Try to narrow down the problem, whether coding or electronic. Don't confuse us and yourself by trying to do everything at once. For example, if you are having problems reading a sensor, make up a simple test case, that tests that sensor (both electrically and in code).
That said, I'll add some pure conjecture. It looks like the variable first is intended to accumulate the input from the keypad. first is local to loop(). That means that it goes out of scope every time loop executes, and its value is lost when loop() terminates and restarts. But, each pass through loop() appears to fetch only one digit. So, first will never accumulate more than the most recent digit. I'd recommend either making first a global variable, or modifying your code so that it fetches a whole value in each iteration of loop().
Also, it looks like you're printing the value of the variable inp to the TFT. You declare inp to have a length of 2, and it looks like you call the routine that converts it to a String with a length of 2 as well. Yet, you go to some effort to get more than one digit into first. I see a conflict there. inp looks like it should be longer, and it looks like you should call toCharArray() with a bigger length.
Reiterating: that's pure conjecture. If you want something better, describe what's happening in better detail.
hi guys,
thanks to all of you for your various help over the duration of this project, and now I can proudly say that the whole project works, what is a number converter from decimal to binary octal and hexadecimal.
thanks again
Toby
if any of you want to see the complete code please just say
Delta_G:
char key = keypad.getKey();
char array[10] = {}; //or as many characters as you want + 1 for the termination
char arrayIndex = 0;
So arrayIndex is 0 at this point. Then you have:
while (key != 35)
{
char key = keypad.getKey();
if (key == 42)
{OK so far. Get a key and compare it to see if it is 42. But then:
array[--arrayIndex] = '\0';
}Remember arrayIndex was 0. So when you do this you are saying array[-1] = '/0'; I don't think -1 is a good index. But then:
array[arrayIndex++] = key ;
You come and put key in the array[-1] It's still not a good index. But the post-increment means it will be 0 next time it is evaluated. But then:
array[arrayIndex--] = '\0';
So now you are putting a '/0' in array[0] which is at least a valid index to that array. But then you've got the -- on it, so the next time through the while loop we will start at -1 instead of 0. So you will go even further off the end of your array with the next character.