Keypad, input three-digit number

Hi, I have a problem regarding the keypad. I need some way to enter the three-digit number via the keypad in a variable, and then compared with the measured value. It is a thermostat that need to be set. I can not seem to me in some reasonable way to enter variables three-digit number. Thanks for any advice.

What have you tried?

http://bit.ly/1hN9Orv

and then compared with the measured value.

Compare the 3 digits you enter with, lets say, an analog value etc. OR transfer the 3 digit number you entered to your set point variable.

I have an analog input from a thermometer. And now I need to specify the number keypad which I will compare with the thermometer. It is a thermostat.

sheep: I have an analog input from a thermometer. And now I need to specify the number keypad which I will compare with the thermometer. It is a thermostat.

Once again, what have you tried? Show us some code. There is little difference between getting characters from a keypad, and receiving characters over Serial.

There is little difference between getting characters from a keypad, and receiving characters over Serial.

Excellent point

I add a simple code:

int Temperature = A0;    // analog input
int relay = 13;      // relay Heating
int setTemperature = 350;  // default temperature

void setup() {
  
  pinMode(relay, OUTPUT);  
}

void loop() {
 
int  sensorValue = analogRead(Temperature); 
if(sensorValue < setTemperature ){  
  
  digitalWrite(relay, HIGH);  
} 
 
if( sensorValue > setTemperature + 10){     // +10 - hysteresis
      
  digitalWrite(relay, LOW);   
                    
}
}

a need “setTemperature” change temperature through keypad.

You haven’t shown us anything that gets keys from a keypad.

That’s the first order of business… get one key, and show us the code.

This demonstrated the need to change “setTemperature” using the keypad and do not know how to do it. Because the code to enter a number from the keyboard is useless to me.
This code is not needed.

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'0','1','2','3'},
  {'4','5','6','7'},
  {'8','9','A','B'},
  {'C','D','E','F'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }
}

This code writes me only the last number you pressed. I need a three-digit number.

keep a counter for the chars received, save each key in an array and increment the counter, when the counter gets to 3 you have your 3-digit number in the array.


Rob

I tried, if I give Serial.print lists only one number and when I send it to the LCD so even one, and even garbage characters. That's why I came to this forum for experienced people. And thank you all in advance.

I tried, if I give Serial.print lists only one number

Because that is all you are reading.

  char customKey = customKeypad.getKey();
  
  if (customKey){

Any non-zero value is true. You really should not be testing custom_key that way. How difficult is it to do it properly?

if(customKey != NO_KEY)

and when I send it to the LCD so even one, and even garbage characters.

So, you elected not to post that code, but you still want us to explain what is wrong with it? Not a snowballs chance in hell of that happening.

That's why I came to this forum for experienced people.

Experienced, yes. But this still isn't the homework hotline.

I tried

Show us what you tried, with a counter and an array of characters etc.


Rob

you put in one number, lets say its 3 you put in a second number, lets say 7. You multiply 3 x 10 and add 7. 37 you put in the third number, lets say 4. You multiply 37 x 10 and add 4, result 374. simple.

Your problem then becomes debouncing the keyboard and also knowing if the number contains the same digit twice