Arduino州未在此范围内声明

时间:2014-10-19 08:31:26

标签: arduino arduino-uno

我目前正在使用arduino开发一个小项目,下面是我的代码:

#include <SoftwareSerial.h>
#include <Adafruit_Fingerprint.h>
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns

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

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {2, 3, 4, 5};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {6, 7, 8}; 

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

#define ledpin 13
#define LOCKED 2
#define PASSWORD_OK 1
#define UNLOCKED 0

//State Variables; initialise to locked state
int LockState = LOCKED;
int position = 0;

void setup()
{
  pinMode(ledpin,OUTPUT);
  digitalWrite(ledpin, HIGH);
  Serial.begin(9600);

  //Initialize state and communications
  setLockState(LOCKED);
  Serial.begin(9600);

}

void loop()
{
  char key = keypad.getKey();
  if(key)  // Check for a valid key.
  {
    switch (key)
    {
//      case '*':
//        digitalWrite(ledpin, LOW);
//        break;
//      case '#':
//        digitalWrite(ledpin, HIGH);
//        break;
      default:
        Serial.print(key);
    }
  }
}

来自Adafruit。但是,当我上传到我的uno时,它一直给我错误:'setLockState' was not declared in this scope.

任何人都可以对此有所了解吗?

1 个答案:

答案 0 :(得分:0)

我认为您没有在代码中声明函数setLockState()。我不知道你的项目细节,但看起来你想通过键盘或指纹来锁定东西。您可以在Adafruit网站上找到biometric-security-box的精彩教程(包括缺少setLockState()功能)。