Hello,
I am new to programming and new to the Arduino community and was hoping one of you could provide some guidance. Basically I am trying to limit two input from keypad. I figured out how to set up the keypad and can correctly display the button I pressed. I am struggling to limit 2-digit number value eg 50. Any advice would be greatly appreciated!
void checknumber(int x){
if (firstnumber == 99) { // Check if this is the first number entered
firstnumber=x;
String displayvalue = String(firstnumber); // Transform int to a string for display
lcd.setCursor(10,0);
lcd.print(displayvalue); // Redraw screen
} else {
if (secondnumber == 99) { // Check if it's the second number entered
secondnumber=x;
String displayvalue = (String(firstnumber) + String(secondnumber));
lcd.setCursor(10,0);
lcd.print(displayvalue);
lcd.print(" " );
}
}
}
If you get the number as an integer rather than some Frankenstein's monster collection of individual String digits then it is easy to test its value and react accordingly if it is out of range
Is 'firstnumber' one of the digits of the number and 'secondnumber' another digit?
If so this is completely the wrong way to go about entering a number.
Otherwise your posted code tells us nothing because you've decided to subscribe to snippets-r-us.
Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting will result in a timeout from the forum.
In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.