'key' was not declared in this scope

Hello, I’m actually preparing a code which will be used to get informations from a 3*4 keypad, to compare them with a written password, and then write a message on a LCD screen.
My problem is that I have the following error message :

exit status 1
‘key’ was not declared in this scope

So I’m wondering why this message appears, because I followed This tutorial (click)
But I still have the same problem. So I’m posting the code with the message, I hope someone could help me.
Thanks in advance

The code :

#include <Keypad.h>
#include <Password.h>
#include <Deuligne.h>
 
 
Deuligne lcd;
 
void setup() {
  Serial.begin(9600);
const byte ROWS = 4; //Création de 4 lignes
const byte COLS = 3; //Création de 3 colonnes
char keys[ROWS][ROWS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'#','0','*'} //Représentation informatisée du clavier achevée
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //Connexion des lignes sur les broches 5, 4, 3 & 2 de l'Arduino
byte colPins[COLS] = {8, 7, 6}; //Connexion des lignes sur les broches 8, 7 & 6
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 
Password password = Password("2703");
 
  lcd.init();
  lcd.clear();
  lcd.backLight(true);
  lcd.noCursor();
}
 
 
 
void loop() {
  lcd.setCursor(0,0); //Fait en sorte d'écrire le message au début de l'afficheur
  lcd.print("Entrez le code"); //Affiche le message "Entrez le code"
 
char getKey(); //Reçoit la valeur du bouton pressé
 
if (key != NO_KEY){
  Serial.println(key); //Si le bouton pressé n'est pas égal à "aucun bouton pressé", alors on l'affiche
}
{
  String keyOne = keypad.waitForKey();
  String keyTwo = keypad.waitForKey();
  String keyThree = keypad.waitForKey();
  String keyFour = keypad.waitForKey();
//Reconnait les valeurs tapées sur le clavier
  String pwd = keyOne + keyTwo + keyThree + keyFour; //Assemble les valeurs pour créer un nombre à quatre chiffres
Serial.println(pwd); //Affiche le code tapé
delay(2000); //Attends 2 secondes
 
 
  if (pwd == 2703)
  {
    Serial.println ("Bienvenue")
    delay(5000);
    password.reset();
  }
{
  if (pwd != 2703)
  {
    Serial.println ("Code faux")
    delay(2000);
    Serial.println ("2 essais restants")
    delay(2000)
    password.reset()
  }
}
}
}
char getKey(); //Reçoit la valeur du bouton pressé

Non.

char key = getKey(); //Reçoit la valeur du bouton pressé

AWOL: char getKey(); //Reçoit la valeur du bouton pressé

Non.

char key = getKey(); //Reçoit la valeur du bouton pressé

Okay, that's a great beginning... Thank you

I changed it, and now it tells me 'getKey' was not declared in this scope

keys.getKey ();

AWOL: keys.getKey ();

I tried with and without the "s" on "keys", and I have the same error message

Sorry "keypad" - brain-fart

Another one, but this is keypad which is not declared this time...

OK, thanks for letting me know.

Hello again, I made the code again, and now it’s like this :

#include <Wire.h> //Intègre une librairie pour communiquer par une liaison spécifique, ici I2C
#include <Keypad.h> //Intègre une librairie pour un clavier matriciel
#include <Password.h> //Intègre une librairie pour simplifier la gestion du mot de passe
#include <Deuligne.h> //Intègre une librairie pour une bonne utilisation de l'afficheur Deuligne


const byte ROWS = 4; //Création de 4 lignes
const byte COLS = 3; //Création de 3 colonnes
char keys[ROWS][ROWS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'#','0','*'} //Représentation informatisée du clavier achevée
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //Connexion des lignes sur les broches 5, 4, 3 & 2 de l'Arduino
byte colPins[COLS] = {8, 7, 6}; //Connexion des lignes sur les broches 8, 7 & 6

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); //Création du clavier
 
Password password = Password("2703");

Deuligne lcd;

void setup() {

  Serial.begin(9600);
  keypad.addEventListener(keypadEvent); //Crée un évènement pour le clavier (ici, l'affichage d'un message)

  Wire.begin(); //Ajoute une liaison I2C
  lcd.init(); //Initialise l'afficheur
  lcd.clear(); //Efface les éventuelles valeurs

  lcd.setCursor(0,0); //Écrit en haut à gauche
  lcd.print("Config"); //Affiche un sample visuel pour voir si la disposition du texte est correcte
  lcd.setCursor(7,0); //Écrit au milieu de la ligne du haut
  lcd.print("Ok"); //Deuxième sample test
  delay(1000);
}

void loop() {
  keypad.getKey();
}
void keypadEvent(KeypadEvent eKey) {
  switch (keypad.getState()) { //Prévoit une action en fonction de la valeur finale
    case PRESSED:
  Serial.print("CHIFFRE: ");
  Serial.println(eKey);
  switch (eKey) {
    case '*': checkPassword(); break; //Action 1 : Quand * est pressé, le code tapé est vérifié
    case '#': password.reset(); break; //Action 2 : Quand # est pressé, le code tapé est réinitialisé
    default: password.append(eKey); //Action 3 : Pour n'importe quelle touche, on retient les valeurs
    
    }
  }
}

void checkPassword() {
  if (password.evaluate()) {
    Serial.println("Bienvenue");
  }else{
    Serial.println("Code faux");
    delay(2000);
    Serial.println("Veuillez réessayer");
  }
}

I don’t have a single error message, except for an error which happens when I want to do a compilation, it tells me that there’s an error during the compilation. What could it be? Thanks in advance

What could it be?

We don't know - why don't you copy it and post it here for us?

AWOL: We don't know - why don't you copy it and post it here for us?

Well, the code is on the previous message, and the error message is :

exit status 1 Erreur lors de la compilation.

Post the full error (in code tags preferably). You can select all text in the (bottom) output window abd copy it; there might also be a button 'copy message' in the title bar of the output window (this might depend on version of the IDE).

Next paste it in your post (as said, preferably using code tags)

Arduino : 1.6.6 (Windows 7), Carte : "Arduino/Genuino Uno"

In file included from Z:\SIN\Programme_Final\Programme_Final.ino:4:0:

C:\Users\yan.pruvot\Documents\Arduino\libraries\Snootlab-Deuligne-c57bca6/Deuligne.h:68:16: error: conflicting return type specified for 'virtual void Deuligne::write(uint8_t)'

   virtual void write(uint8_t);

                ^

In file included from C:\Program Files\arduino-1.6.6-windows\arduino-1.6.6\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files\arduino-1.6.6-windows\arduino-1.6.6\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files\arduino-1.6.6-windows\arduino-1.6.6\hardware\arduino\avr\cores\arduino/Arduino.h:224,

                 from sketch\Programme_Final.ino.cpp:1:

C:\Program Files\arduino-1.6.6-windows\arduino-1.6.6\hardware\arduino\avr\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

Z:\SIN\Programme_Final\Programme_Final.ino:20:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

 Password password = Password("2703");

                                    ^

exit status 1
Erreur lors de la compilation.

  Ce rapport contiendrait plus d'informations si l'option
  "Montrer les informations de sortie pendant la compilation"
  était activée dans Fichier > Préférences.

The very last message in compile error not very helpful imo. You need to scroll up. Your compiler is trying to help you!

This looks fishy: Password password = Password("2703");

FullOfBadIdeas: This looks fishy: Password password = Password("2703");

Looks OK to me - a cast would suppress the warning.

We need to see the library that's giving you errors.

The write() method is declared virtual in the Print class. That means that any class, like Deuligne, that inherits from Print needs to implement the write() methods EXACTLY as Print defines them. The Deuligne class does not.

Years ago, the Print class changed the definition of the write() methods to require that they return the number of characters written, rather than returning nothing. You need to fix the Deuligne class to play by the new rules.

PaulS: You need to fix the Deuligne class to play by the new rules.

... or download the Arduino-1.0 branch instead of master: https://github.com/Snootlab/Deuligne/archive/Arduino-1.0.zip

PaulS: The write() method is declared virtual in the Print class. That means that any class, like Deuligne, that inherits from Print needs to implement the write() methods EXACTLY as Print defines them. The Deuligne class does not.

Years ago, the Print class changed the definition of the write() methods to require that they return the number of characters written, rather than returning nothing. You need to fix the Deuligne class to play by the new rules.

So you're telling me...I don't have the right Library and I need to add another one?

No, he's telling you that you can fix the one you've got. It's there in his last sentence.

AWOL: No, he's telling you that you can fix the one you've got. It's there in his last sentence.

Okay...considering that I'm a d*** with Arduino (I'm forced to use it), in simple and easy-to-understand language, how is this sorcery possible?