#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Lightbulb Compiler error in Arduino


    I inserted the keypad libraries into my Arduino, and I got an error saying 'Keypad does not name a type.' It pointed to the function highlighted in blue. What task should I preform to clear this error? Thanks

    #include <Keypad.h>

    char* secretCode = "1B28";
    int position = 0;

    const byte rows = 4;
    const byte cols = 4;
    char keys[rows][cols] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','C'},
    {'*','0','#','D'}
    };

    byte rowPins[rows] = {4, 5, 6, 7};
    byte colPins[cols] = {1, 2, 3, 4};

    Keypad kpd = Keypad(makeKeymap(keys),
    rowPins, colPins,
    rows, cols);

    int plusPin = 8;


    void setup()
    {
    pinMode(plusPin, OUTPUT);

    setLocked(true);
    }


    void loop()
    {
    char key = keypad.getKey();
    if (key == '*' || key == '#') {
    position = 0;
    setLocked(true);
    }

    if (key == secretCode[position]) {
    position++;
    }

    if (position == 6) {
    setLocked(false);
    }
    delay(50);
    }


    void setLocked(int locked)
    {
    if (locked) {
    digitalWrite(plusPin, HIGH);

    }
    else {
    digitalWrite(plusPin, LOW);

    }
    }
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,894
    Rep Power
    481
    You've studied the arduino Keypad tutorial?
    Did you compile with c++ as I believe you should have?
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo