Hallo zusammen
Moechte gerne die 16 Keypad Tasten in eine If Abfage abfragen
bekomme die Fehlermeldung
error: ISO C++ forbids comparison between pointer and integer
Komme nicht weiter kann Mir jemand helfen
/*
Keypad sketch
prints the key pressed on a keypad to the serial port
*/
const int numRows = 4; // number of rows in the keypad
const int numCols = 4; // number of columns
const int debounceTime = 20; // number of milliseconds for switch to be stable
// keymap defines the character returned when the corresponding key is pressed
const char keymap[numRows][numCols] = {
{ '1', '2', '3', 'A' } ,
{ '4', '5', '6' , 'B' } ,
{ '7', '8', '9' , 'C' } ,
{ '*', '0', '#' , 'D' }
};
// this array determines the pins used for rows and columns
const int rowPins[numRows] = { 9, 8, 7, 6 }; // Rows 0 through 3
const int colPins[numCols] = {5, 4, 3, 2}; // Columns 0 through 2void setup()
void setup()
{
Serial.begin(9600);
for (int row = 0; row < numRows; row++)
{
pinMode(rowPins[row],INPUT); // Set row pins as input
digitalWrite(rowPins[row],HIGH); // turn on Pull-ups
}
for (int column = 0; column < numCols; column++)
{
pinMode(colPins[column],OUTPUT); // Set column pins as outputs for writing
digitalWrite(colPins[column],HIGH); // Make all columns inactive
}
}
void loop()
{
char key = getKey();
if( key != 0) { // if the character is not 0 then it's a valid key press
Serial.print("Got key ");
Serial.println(key);
}
if(strcmp(const char key, "1") == 0) // fehler bei der Abfrage
{
Serial.print("neuerkey "); //error: ISO C++ forbids comparison between pointer and integer
}
}
// returns with the key pressed, or 0 if no key is pressed
char getKey()
{
char key = 0; // 0 indicates no key pressed
for(int column = 0; column < numCols; column++)
{
digitalWrite(colPins[column],LOW); // Activate the current column.
for(int row = 0; row < numRows; row++) // Scan all rows for a key press.
{
if(digitalRead(rowPins[row]) == LOW) // Is a key pressed?
{
delay(debounceTime); // debounce
while(digitalRead(rowPins[row]) == LOW)
; // wait for key to be released
key = keymap[row][column]; // Remember which key was pressed.
}
}
digitalWrite(colPins[column],HIGH); // De-activate the current column.
}
return key; // returns the key pressed or 0 if none
}
bye juergen