Go Down

Topic: problem with keypad library? (Read 1 time) previous topic - next topic


Feb 09, 2012, 06:21 pm Last Edit: Feb 09, 2012, 06:27 pm by AWOL Reason: 1
I have an arduino mega 2560 i just dowloaded the keypad library and open the first example ( custom keypad) the code is this:
Code: [Select]

/* @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] = {
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(){
void loop(){
 char customKey = customKeypad.getKey();
 if (customKey != NO_KEY){

but when i compile the program i get this errors :

CustomKeypad:48: error: redefinition of 'const byte ROWS'
CustomKeypad:11: error: 'const byte ROWS' previously defined here
CustomKeypad:49: error: redefinition of 'const byte COLS'
CustomKeypad:12: error: 'const byte COLS' previously defined here
CustomKeypad:51: error: redefinition of 'char hexaKeys [4][4]'
CustomKeypad:14: error: 'char hexaKeys [4][4]' previously defined here
CustomKeypad:57: error: redefinition of 'byte rowPins [4]'
CustomKeypad:20: error: 'byte rowPins [4]' previously defined here
CustomKeypad:58: error: redefinition of 'byte colPins [4]'
CustomKeypad:21: error: 'byte colPins [4]' previously defined here
CustomKeypad.cpp: In function 'void setup()':
CustomKeypad:63: error: redefinition of 'void setup()'
CustomKeypad:26: error: 'void setup()' previously defined here
CustomKeypad.cpp: In function 'void loop()':
CustomKeypad:67: error: redefinition of 'void loop()'
CustomKeypad:30: error: 'void loop()' previously defined here

Is anyone able to help me with that ! I am not that experienced with programming in C ! I am gessing there is something to do with syntax ?????? but i am not so sure . PLZ HELP !

Moderator edit: CODE TAGS added.  You may wish to give your keyboard a good shake - your "?" appears to be stuck down.


See this thread from yesterday: http://arduino.cc/forum/index.php/topic,90458.0.html


I posted my library link on that other thread. OP is welcome to use my library.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up