Pages: [1]   Go Down
Author Topic: problem with keypad library?  (Read 743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an arduino mega 2560 i just dowloaded the keypad library and open the first example ( custom keypad) the code is this:
Code:
/* @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);
  }
}

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.
« Last Edit: February 09, 2012, 12:27:31 pm by AWOL » Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7183
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I posted my library link on that other thread. OP is welcome to use my library.
Logged


Pages: [1]   Go Up
Jump to: