Keypad to relay

Hello,
i dont work with the arduino, we work in school with the texas instruments but the programming is the same. I think the arduino forum is more helpful than the energia forum.

I have a keypad 4x4 and want to control relays with my script. I wrote a script, but it doesn´t work.
Can anyone help me with my problem?

#include <Keypad.h>
const byte numRows= 4; //number of rows on the keypad
const byte numCols= 4; //number of columns on the keypad
//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols]=
{
{‘1’, ‘2’, ‘3’, ‘A’},
{‘4’, ‘5’, ‘6’, ‘B’},
{‘7’, ‘8’, ‘9’, ‘C’},
{’*’, ‘0’, ‘#’, ‘D’}
};
//Code that shows the the keypad connections to the arduino terminals
byte rowPins[numRows] = {PF_3,PB_3,PC_4,PC_5}; //Rows 0 to 3
byte colPins[numCols]= {PC_7,PD_6,PD_7,PF_4}; //Columns 0 to 3

//initializes an instance of the Keypad class
Keypad ourKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

int REL = PA_7;

void setup()
{
pinMode(REL,OUTPUT);
Serial.begin(9600);
Serial.begin(9600);//sets baud rate for serial communication
}
char lastKey=0;
void loop()
{char keypressed = ourKeypad.getKey();
if (keypressed != NO_KEY);
{
Serial.print(keypressed);
}
//} These two line are your problem
//{
//char key = keypad.getKey(); // keypad was not declared anywhere, I assume it was meant to be this:

char key = ourKeypad.getKey();
if (int(key) == 1) {
digitalWrite(REL, LOW);
delay(1000);
digitalWrite(REL, HIGH);
delay(1000);
}
}

Please use code tags (</> button on the toolbar), not quote tags.

Please explain exactly what you mean by “it doesn’t work”.

  if (int(key) == 1) {

If the key labeled 1 is pressed, the VALUE stored in key will be '1'. Casting it to an int will NOT make the value 1, no matter how much you wish it would.

void loop()  {
  char keypressed = ourKeypad.getKey();
  if (keypressed != NO_KEY);
  {
    Serial.print(keypressed);
  }

  char key = ourKeypad.getKey();
  if (int(key) == 1) {

You are calling getKey() TWICE in your loop. The results of one you just display and the results of the other you act on. Did you want to ignore have the button presses?!? You should get rid of 'key' and use 'keypressed' for both.

Thanks for your help. I helped myself by using the password library so i can control the relays with the passwords.