Pages: [1]   Go Down
Author Topic: How do I declare a new class definition  (Read 1150 times)
0 Members and 1 Guest are viewing this topic.
Centurion RSA
Offline Offline
Full Member
Karma: 0
Posts: 166
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I declare the following so that the new class can be seen by other modules.
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
byte rowPins[ROWS] = {2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,8,9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
All of the above is declared in a header for the main module but I need to be able to call the keypad like this
and like this
whichkey = keypad.getKey();
from other modules. I get this error compiling with a CMake make file :-  undefined reference to `Keypad::Keypad(char*, unsigned char*, unsigned char*, unsigned char, unsigned char, unsigned char)'.
There are many more like this all referring to class definitions.
How to do please?



Rather people think you to be a fool than you open your mouth and confirm it.

Seattle, WA USA
Online Online
Brattain Member
Karma: 640
Posts: 50345
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I get this error compiling with a CMake make file
When compiling what with a CMake make file?

Do you get the same error when compiling with the Arduino IDE?

If the code shown in the top window is placed inside a class, you will need to refer to the members of that class (keypad, etc.) using an instance of that class. key = keypad.getKey(); will not work, because keypad is a member variable.
« Last Edit: May 29, 2011, 05:07:09 pm by PaulS » Logged

Red Sea, Saudi Arabia
Offline Offline
God Member
Karma: 12
Posts: 579
..On The Red Sea
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Take a look at:

Which is Alexander's tutorial on Libraries.... Well done!

Regards, Terry King  ..On the Red Sea at  LEARN! DO! (Arduino Boards, Sensors, Parts @

Pages: [1]   Go Up
Jump to: