error: 'keypad' does not name a type In function '

Hi guys, i found a script online but cant get this working… check this out:::

I get this error:
error: ‘keypad’ does not name a type In function ‘void setup()’:
In function ‘boolean getArmCode()’:
In function ‘boolean getDisarmCode()’:

/******************************************************************************************

#define ROWS 4
#define COLS 3

//Define all the bomb states
#define ON 0
#define READY 1
#define ARMED 2
#define DISARMED 3
#define DETONATED 4

keypad kpd = keypad(ROWS, COLS);//create a new keypad

int second=30, minute=10, hour=0; // declare time variables
int bombState=0; //1 = Ready, 2 = Armed, 3 = Disarmed, 4 = detonated
int repeat=0;//flag to prevent repeat of getArmCode();
int repeatDisarm=0;//flag to prevent repeat of getDisarmCode();
int repeatBuzzer=0;//flag to prevent buzzer from running multiple times.
int tether = 2;//pin that contains the tether.
int disarmPin = 3;//pin that the red pushbutton is plugged into.
int speakerPin = 5;//pin that the piezo buzzer is connected to.
int pinStatus = 0;//stores value of the tether pin.
int disarmPinStatus = 0;//stores value of the disarm pin.

char ArmCode = “7355608”;//code to arm the bomb
char disarmCode = “3567546”;//code to disarm the bomb
char CANCEL_KEY = ‘*’;//stores the cancel key variable.

char notes = "A c A c A c E "; // a space represents a rest
const byte length = sizeof(notes); // the number of notes
byte beats[length] = { 1, 1, 1, 1, 1, 1, 1, 4};
char names = { ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘a’, ‘b’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘A’, ‘B’ };
unsigned int tones = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 587, 659, 698, 784, 880, 988 };

//Above is the beats the note plays for
byte tempo = 1000;

void setup()
{
Serial.begin(9600);
kpd.init();
clearLCD();
backlightOn();
pinMode(disarmPin, INPUT);//sets the input pin for the pushbutton.
pinMode(speakerPin, OUTPUT);//sets the output pin for the piezo buzzer
}

void loop(){
switch (bombState) {
/*****************************************************
*Initial bomb state, waiting for teather.
*
*******************************************************/
case ON:

pinStatus = digitalRead(tether);
if (pinStatus == HIGH) {
selectLineOne();
delay(100);
Serial.print(“Attach Tether”);
}
else {
bombState = READY;
delay(500);
}
break;

/***********************************************************
*Ready state prepares bomb, waits for arm code to be input
*
************************************************************/
case READY:

clearLCD();
selectLineOne();
delay(100);
Serial.print(“Enter Code”); //Notify user of status.

if (getArmCode() == true) {

//Make sure tether hasn’t been removed
pinStatus = digitalRead(tether);
if (pinStatus == HIGH) { //if the tether has been removed,
selectLineOne();
delay(100);
Serial.print(“Tether Removed”); //make it known
delay(1000);
clearLCD();
bombState = DETONATED; //and set off bomb.
}

else { //if the tether is still connected, print “correct”.
clearLCD();
selectLineOne();
delay(100);
Serial.print(“Correct”);
delay(500);
clearLCD();
bombState = ARMED; //Start countdown
}
}//Close getArmCode(); = true

if (getArmCode() == false) {

//Make sure tether hasn’t been removed
pinStatus = digitalRead(tether);
if (pinStatus == HIGH) { //if the tether has been removed,
selectLineOne();
delay(100);
Serial.print(“Tether Removed”); //make it known
delay(1000);
clearLCD();
bombState = DETONATED; //and set off bomb.
}

else {
clearLCD();
selectLineOne();
delay(100);
Serial.print(“Incorrect”);//if code fails, and tether is connected, print “Incorrect”
}
}// Close getArmCode(); = false.

break;

/**************************************************
*Armed state. Countdown starts, waits for pushbutton to be pressed.
*If button is pressed, wait for code from keypad.
***************************************************/

case ARMED:

disarmPinStatus = digitalRead(disarmPin);
if (disarmPinStatus == LOW) {
selectLineOne();
delay(100);
Serial.print(“Enter Code:”); //if disarm button is pressed, ask user to input code.

if (getDisarmCode() == true) {

//Make sure tether hasn’t been removed
pinStatus = digitalRead(tether);

if (pinStatus == HIGH) { //if the tether has been removed,
selectLineOne();
delay(100);
Serial.print(“Tether Removed”); //make it known
delay(1000);
clearLCD();
bombState = DETONATED; //and set off bomb.
}

else {
clearLCD();
selectLineOne();
delay(100);
Serial.print(“Correct”); //if code is correct, and tether is connected, print “Correct”.
delay(500);
clearLCD();
bombState = DISARMED; //and set bombState to disarmed.
break;
}
} //close getDisarmCode(); = True

if (getDisarmCode() == false) {

//Make sure tether hasn’t been removed
pinStatus = digitalRead(tether);

if (pinStatus == HIGH) { //if the tether has been removed,
selectLineOne();
delay(100);
Serial.print(“Tether Removed”); //make it known
delay(1000);
clearLCD();
bombState = DETONATED; //and set off bomb.
}

else {
clearLCD();
selectLineOne();
delay(100);
Serial.print(“Try Again”);//if code fails, notify user
//second = 1; //and remove all the remaining seconds.

if (second >= 15) {
second = second - 15;
}

else {
if (minute == 0) {
second=1; //detonate.
}
if (minute > 0) {
second = 60 - (15 - second);
minute = minute - 1;
}

if (hour > 0 && minute == 0) {
second = 60 - (15 - second);
minute = 59;
hour = hour - 1 ;
}

//else {
//second=1;// erase seconds from count after button press.
//}
}
}
} //close getDisarmCode(); = false

} //close disarmPinStatus(); = true

else {
countdown(); //if disarmpin has not been pressed, continue countdown.
}

break;

/**************************************************************
*DISARMED. Counter stopped, displays “bomb disarmed”
*
**************************************************************/

case DISARMED:

selectLineOne();
delay(100);
Serial.print(“Bomb Disarmed”); //bomb has been disarmed, inform user.
break;

/*******************************************************
*Detonated. activate buzzer for 8 beeps, then 1 long.
*Print "Have A Nice Day. to LCD.
********************************************************/

case DETONATED:

if (repeatBuzzer == 0) { //make sure buzzer for loop has not already been run.

digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(5000);//wait 5 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
repeatBuzzer = 1;//set flag to prevent code from looping again.

/* for (int i = 0; i < length; i++) {
if (notes == ’ ') {
delay(beats * tempo); // rest
* }*

* else {*
playNote(notes, beats * tempo);
* }*

* // pause between notes*
* delay(tempo / 2);*
* repeatBuzzer = 1; //set flag to prevent code from looping again.*
_ }//close for loop*/
* }//close repeatBuzzer.*_

* else {*
* selectLineOne();*
* delay(100);*
* Serial.print(“Have A Nice Day”); //loop message informing user of bomb detonation.*
* }*
* }//closes switch*
}//closes loop

Where is the getArmCode function? Where is the getDisarmCode function()?

http://pastebin.com/f57045830

Here is the whole script!

And you've got keypad.h?

yea.... Are there many different keypad.h files?

Should i add something to keypad.h ?

Have you tried the codes? You get it to work? ;D

Waiting on reply!

You could try this: http://www.arduino.cc/playground/Code/Keypad :)

Ty for fast reply!

I did try the "keypad link" you sent me, and i added the files...

Are you able to test the script out and see if it fails at your place?

"error: 'keypad' does not name a type In function 'void setup()': In function 'boolean getArmCode()': In function 'boolean getDisarmCode()': "

I copied and pasted your code into a sketch, and got an error message indicating that the compiler couldn’t find keypad.h.

I looked in the libraries directory, under Keypad, and found Keypad.h. When I changed #include <keypad.h> to #include <Keypad.h>, I get the same error that you get.

When I change keypad kpd = keypad(…) to Keypad kpd = Keypad(…), that error goes away.

It’s replaced by another, because you aren’t using the library correctly, but, I can’t fix that one for you, because the solution is hardware dependent.

hmmm… nothing you can do to help me?

This is what the top of my sketch that uses the Keypad library looks like:

/* ===================================
   Pins on keypad are numbered
   from left to right, 0 - 8. Pins
   0 and 8 are not connected. Pins
   1, 3, and 5 are for the rows.
   Pins 2, 4, 6, and 7 are for the
   columns. The pins on the keypad
   are connected to pins 2 - 8 on
   the Arduino in this order:
   K 1 -> A 7
     2 ->   5
     3 ->   8
     4 ->   2
     5 ->   6
     6 ->   3
     7 ->   4
====================================== */

#include <Keypad.h>

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

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Compare that to yours, and you’ll see that there is a lot of stuff you left out. The rowPins and colPins arrays depend on how YOU have connected the keypad to the Ardunio. The keys array depends on what you get when you poke the keypad with a multi-meter.

That makes keys, rowPins, and colPins hardware dependent, which means that only you will be able to get it working. There are enough clues here and here

http://www.arduino.cc/playground/Code/Keypad

to get you going.

Well, the thing is that i cant even get this stuff over to my board^^ Im kinda new to this, and brought this to make a "fake bomb" for scenario on airsoft... Im planning to learn this, but first of all i just need this stuff going ;D

Well, the thing is that i cant even get this stuff over to my board^^

You need to get the hardware sorted out before the programming is going to work.

Im kinda new to this...

Really. I hadn't considered that...

Im planning to learn this, but first of all i just need this stuff going

"I'm going to learn something, as soon as this works". Well, I hope that works out for you. Most people try that the other way around with better results.