Skip to main content

I am trying to get the value of a key pressed and set it to return a value to use in a loop. In the code below the Print(t) does not show anything

enter code here

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
    {'1', '2', '3', 'A'},
    {'4', '5', '6', 'B'},
    {'7', '8', '9', 'C'},
    {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; 
byte colPins[ROWS] = {5, 4, 3, 2};    
Keypad customKeypad = Keypad(makeKeymap(hexaKeys),rowPins,colPins,ROWS,COLS;                                  

void setup() {
    Serial.begin(9600);
 }

 void loop()
{
    int t; 
    switch ( customKeypad.getKey())
    {
    case 'A':
        t = 8;
        break;
    case '2':
        t = 9;
        break;
    }
    return t;
    Serial.print(t);
}

I am trying to get the value of a key pressed and set it to return a value to use in a loop. In the code below the Print(t) does not show anything

enter code here

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; 
byte colPins[ROWS] = {5, 4, 3, 2};    
Keypad customKeypad = Keypad(makeKeymap(hexaKeys),rowPins,colPins,ROWS,COLS;                                  

void setup() {
Serial.begin(9600);
 }

 void loop()
{
int t; 
switch ( customKeypad.getKey())
{
case 'A': t = 8; break;
case '2': t = 9; break;
}
return t;
Serial.print(t);
}

I am trying to get the value of a key pressed and set it to return a value to use in a loop. In the code below the Print(t) does not show anything

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
    {'1', '2', '3', 'A'},
    {'4', '5', '6', 'B'},
    {'7', '8', '9', 'C'},
    {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; 
byte colPins[ROWS] = {5, 4, 3, 2};    
Keypad customKeypad = Keypad(makeKeymap(hexaKeys),rowPins,colPins,ROWS,COLS;                                  

void setup() {
    Serial.begin(9600);
}

void loop()
{
    int t; 
    switch (customKeypad.getKey())
    {
    case 'A':
        t = 8;
        break;
    case '2':
        t = 9;
        break;
    }
    return t;
    Serial.print(t);
}
Source Link

Switch Case Return , Return not printing

I am trying to get the value of a key pressed and set it to return a value to use in a loop. In the code below the Print(t) does not show anything

enter code here

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; 
byte colPins[ROWS] = {5, 4, 3, 2};    
Keypad customKeypad = Keypad(makeKeymap(hexaKeys),rowPins,colPins,ROWS,COLS;                                  

void setup() {
Serial.begin(9600);
 }

 void loop()
{
int t; 
switch ( customKeypad.getKey())
{
case 'A': t = 8; break;
case '2': t = 9; break;
}
return t;
Serial.print(t);
}