hi,
I am relatively new to arduino, but having a good time experimenting.
I am trying to get the keypad library to work with the example program, using arduino 1.0, and getting the following errors.
I have tried a variety of things, but cant figure out what i am doing wrong. i realise it must be something simple, but any assistance would be welcome!
Program:
#include <Keypad.h>
/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
//#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 != NO_KEY){
Serial.println(customKey);
}
}
compilation errors:
CustomKeypad:50: error: redefinition of 'const byte ROWS'
CustomKeypad:13: error: 'const byte ROWS' previously defined here
CustomKeypad:51: error: redefinition of 'const byte COLS'
CustomKeypad:14: error: 'const byte COLS' previously defined here
CustomKeypad:53: error: redefinition of 'char hexaKeys [4][4]'
CustomKeypad:16: error: 'char hexaKeys [4][4]' previously defined here
CustomKeypad:59: error: redefinition of 'byte rowPins [4]'
CustomKeypad:22: error: 'byte rowPins [4]' previously defined here
CustomKeypad:60: error: redefinition of 'byte colPins [4]'
CustomKeypad:23: error: 'byte colPins [4]' previously defined here
CustomKeypad.cpp: In function 'void setup()':
CustomKeypad:65: error: redefinition of 'void setup()'
CustomKeypad:28: error: 'void setup()' previously defined here
CustomKeypad.cpp: In function 'void loop()':
CustomKeypad:69: error: redefinition of 'void loop()'
CustomKeypad:32: error: 'void loop()' previously defined here