Go Down

Topic: compile when I get the message ' setLocked ' was not Declared In This scope (Read 1 time) previous topic - next topic

nmunoz


hello, I need to work with the keyboard 3 * 4, but when I compile I get this mesaje ,
 ' This was not Declared In scope

and and I tried everything but it does not work . I could help please .
I leave copy of the program .








#include <Keypad.h>

char  codigosecreto = '12345';
int   position = 0;
const byte ROWS = 4; // cuatro filas
const byte COLS = 3; // tres columnas

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'},
};

byte rowPins[ROWS] = { 1, 2, 3, 4 };      // Conectar teclado ROW0, ROW1, ROW2 y Row3 a estos pines de Arduino
byte colPins[COLS] = { 5, 6, 7 };         // Conectar teclado Col"0" , col"1" y col"2" a estos pines de Arduino .
Keypad keypad1 = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int Rojo = 9;
int Verde = 10;

void setup () {
  pinMode (Rojo, OUTPUT);
  pinMode (Verde, OUTPUT);
  setLocked(true)

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

      if (position == 4)
      {
        setLocked(false);
      }

      delay(100);


      void setLocked(int Locked) {
        if (locked)
        {
          digitalWrite(redPin, HIGH);
          digitalWrite(greenPin, LOW);
        }
        else
        {
          digitalWrite(redPin, LOW);
          digitalWrite(greenPin, HIGH);
        }
      }
    }

larryd

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Gabriel_swe

Compiler is right. setLocked is not declared in your code, but you have codigosecreto and other variables declared.

ChrisTenone

What, I need to say something else too?

6v6gt

... and setLocked(true) should be terminated with a semi-colon ';'
and the '{' following setLocked(true) should be replaced with a '}'

Go Up