77Views3Replies

Author Options:

when using for loop with keypad to countdown what i pressed it types 53 instead of typing 9 and so on ? Answered

                     

#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] =
{
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {31,33,35,37};
byte colPins[COLS] = {39,41,43};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

  int x=0;
  void setup() {
   Serial.begin(9600);

  }

  void loop() {
 
     char key = keypad.getKey();
 
 
     if (key != NO_KEY){
      x=key;
    for(int i=x;i>-1;i--){
     Serial.println(i);
     delay(1000);
   
   
     
  }
    
      }}

Tags:arduino

Discussions

None
seandogue

4 years ago

It appears to me that you're seering the ascii code rather than the characters associated with those ascii codes. Use what I wrote in a google search and you'll find your answer

None
AbdallahS2seandogue

Answer 4 years ago

if you could please edit my codes so that it countsdown what i press thanks in advance

None
Downunder35mAbdallahS2

Answer 4 years ago

You have to post the stuff twice hoping to get a faster response (or different aswers) and now you want someone else to edit your code?
First rule of learning is to learn yourself ;)
The suggestions are good, there is plenty of tutorials and code libraries available to study ...