hello, I got this error after adding a line to the setup function:
updatearmed:1:15: error: a function-definition is not allowed here before '{' token
void armedup(){
^
updatearmed:8:1: error: expected '}' at end of input
}
^
exit status 1
'qtestcon' was not declared in this scope
this repeats several times for every function.
//#include <avr/wdt.h>
#include <Wire.h>
#include <AsyncTimer.h>
#include <Adafruit_Fingerprint.h>
AsyncTimer t(1);
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 7, d7 = 6;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int lastcounter;
String options[] = {"add", "remove", "exit"};
#define testdelay 750
#define testr 240
#define testdis 50
bool printing;
int printc;
int counter = 0;
bool counteron = false;
bool armed = false;
bool showa = false;
bool inmenu = false;
int items = 0 ;
bool waiting = true;
bool curentarmed;
int com, lcom;
int testcounter, ltestcounter;
bool shouldtest = false;
bool first = true;
bool autotest = true;
bool startsysarmed;
bool testing = false;
int systcounter;
int lsystcounter;
bool lasttest;
bool authenticated = false;
int a, la;
#include <EEPROM.h>
void setup()
{
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
analogWrite(A5, 255);
analogWrite(A4, 0);
//wdt_enable(WDTO_8S);
while (qtestcon() == false || lcdtest() == false ) {
lcd.clear();
lcd.print(F("waiting"));
if (lcdtest() == false) {
Serial.println(F("lcd"));
}
else {
Serial.println(F("microbit"));
}
}
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(A0, INPUT);
pinMode(A2, INPUT);
digitalWrite(A3, HIGH);
pinMode(A3, OUTPUT);
digitalWrite(A3, HIGH);
lcd.begin(16, 2);
pinMode(8, OUTPUT);
pinMode(13, INPUT);
pinMode(A1, OUTPUT);
pinMode(A2, INPUT);
Serial.begin(9600);
// For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println(F("\n\nAdafruit finger detect test"));
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println(F("Found fingerprint sensor!"));
} else {
Serial.println(F("Did not find fingerprint sensor :("));
// resetr();
}
finger.getTemplateCount();
Serial.print(F("Sensor contains ")); Serial.print(finger.templateCount); Serial.println(F(" templates"));
}
void loop() // run over and over again
{
if (Serial.available()) {
String word1 = Serial.readString();
word1.trim();
String word2 = F("test");
if (word1 == "257" || authenticated == true) {
Serial.println(F("correct"));
delay(100);
if (!authenticated) {
Serial.println(F("authenticated"));
}
while (Serial.available() == false && !authenticated) {
}
if (!authenticated) {
word1 = Serial.readString();
word1.trim();
}
authenticated = true;
Serial.println(word1);
if (word1.equals(word2)) {
Serial.println(F("testing"));
if (testcon()) {
Serial.println(F("functional"));
}
else {
Serial.println(F("error"));
}
}
else {
if (word1.equals(F("qtest"))) {
Serial.println(F("quiet testing"));
Serial.println(qtestcon());
}
else {
if (word1.equals(F("toggle"))) {
armedup();
if (armed) {
}
else {
}
if (qtestcon()) {
digitalWrite(8, HIGH);
delay(750);
digitalWrite(8, LOW);
delay(1000);
Serial.println(F("done"));
lcd.clear();
lcd.print("toggled");
armedup();
Serial.println(armed);
}
else {
Serial.println("error");
}
}
else {
if (word1.equals(F("toggle testing"))) {
if (autotest) {
autotest = false;
Serial.println(F("testing disabled"));
}
else {
autotest = true;
Serial.println(F("testing enabled"));
}
}
else {
if (word1.equals(F("syst check"))) {
Serial.println(F("starting"));
lcd.clear();
lcd.print(F("testing now"));
delay(1000);
lcd.clear();
autotest = false;
armedup();
startsysarmed = armed;
testing = true;
}
else {
if (word1.equals(F("eeprom"))) {
Serial.println(EEPROM.read(1));
}
else {
if (word1.equals(F("ereset"))) {
EEPROM.write(1, 0);
Serial.println(F("reset"));
}
else {
if (word1.equals(F("disr"))) {
Serial.println(F("ok"));
lcd.clear();
lcd.noDisplay();
delay(100);
lcd.display();
}
else {
if (word1.equals(F("reset")) || word1.equals(F("r"))) {
Serial.println("reseting.....");
delay(1000);
resetr();
}
else {
Serial.println(F("Unknown word"));
}
}
}
}
}
}
}
}
}
}
else {
Serial.println("wrong code" + word1);
}
}
if (inmenu == false) {
if (digitalRead(A0) == HIGH && waiting == false) {
waiting = true;
int numalarms = EEPROM.read(1);
EEPROM.write(1, numalarms + 1);
Serial.println("yes " + numalarms);
while (digitalRead(A0) == HIGH) {
}
}
else {
delay(10);
if (digitalRead(A0) == LOW && waiting == true) {
waiting = false;
}
}
getFingerprintIDez();
t.handle();
lcd.clear();
lcd.setCursor(0, 1);
t.setInterval([]() {
armedup();
if (!printing) {
if (armed) {
Serial.println(F("armed"));
}
if (!armed) {
Serial.println(F("disarmed"));
}
}
counter++;
com++;
testcounter++;
if (authenticated) {
a++;
}
if (testing) {
systcounter++;
Serial.println(systcounter);
}
}, 1000);
if (counter >= lastcounter + 10) {
showa = false;
}
if (counter >= 1000) {
counter = 0;
lastcounter = 0;
}
if (a >= la + 10) {
if (authenticated) {
Serial.println("authentication expired");
}
authenticated = false;
}
if (a >= 10) {
a = 0;
la = 0;
}
if (systcounter >= lsystcounter + 1000) {
if (testing) {
testing = false;
armedup();
if (armed == startsysarmed) {
Serial.println(F("true"));
lasttest = true;
testing = false;
autotest = true;
}
else {
lasttest = false;
Serial.println(F("false"));
}
}
}
if (systcounter >= 1000) {
systcounter = 0;
lsystcounter = 0;
}
if (com >= lcom + testr) {
if (autotest) {
testcon();
}
lcom = com;
}
if (com >= 1000) {
com = 0;
lcom = 0;
}
if (com >= lcom + testr - 15) {
if (autotest) {
if (!printing) {
Serial.println("test");
printing = true;
printc = 100;
}
else {
printc--;
if (printc == 0) {
printing = false;
}
}
}
}
if (testcounter >= ltestcounter + testdis - 15) {
if (autotest) {
if (!printing) {
Serial.println("test");
printing = true;
printc = 100;
}
else {
printc--;
if (printc == 0) {
printing = false;
}
}
}
}
if (testcounter >= ltestcounter + testdis) {
if (autotest) {
shouldtest = true;
}
ltestcounter = testcounter;
}
if (testcounter >= 1000) {
testcounter = 0;
ltestcounter = 0;
}
if (showa == true) {
lcd.setCursor(0, 0);
lcd.print(F("accepted"));
lcd.setCursor(0, 1);
}
else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(EEPROM.read(1));
lcd.setCursor(0, 1);
}
armedup();
if (armed == true) {
lcd.print(F("armed"));
}
else {
lcd.print(F("disarmed"));
if (shouldtest == true) {
shouldtest = false;
if (qtestcon() == true) {
EEPROM.update(1, 0);
}
else {
testcon();
}
}
}
}
else {
lcd.clear();
if (digitalRead(9) == HIGH) {
items++;
}
if (items > 2) {
items = 0;
}
lcd.print(options[items]);
delay(10);
if (digitalRead(10) == HIGH) {
if (items == 2) {
inmenu = false;
}
if (items == 1) {
bool ready = false;
int current = finger.templateCount;
while (!ready) {
if (digitalRead(9) == HIGH) {
current++;
if (current > finger.templateCount) {
current = 3;
}
}
if (finger.templateCount != 2) {
lcd.clear();
delay(10);
lcd.print(current);
delay(500);
if (digitalRead(10) == HIGH) {
ready = true;
inmenu = false;
Serial.println("removing " + current);
removef(current);
lcd.clear();
lcd.print("done");
}
}
else {
lcd.clear();
lcd.print(F("none to remove"));
delay(1000);
inmenu = false;
}
}
}
if (items == 0) {
enroll(finger.templateCount + 1);
}
if (items < 0) {
items = 2;
}
}
}
}