I am working on a 2 button calculator and there is an error message in the compiler saying:
undefined reference to `setup'
(I am using Arduino IDE 2.0)
This is the code that I think is buggy:
void setup(bool startLoadingScreen = true) {
// Start the LCD:
lcd.begin();
lcd.backlight();
lcd.clear();
// Start the Serial Monitor for debugging:
Serial.begin(9600);
// Create the custom characters for the LCD:
lcd.createChar(0, MidEmpty);
lcd.createChar(1, LeftEmpty);
lcd.createChar(2, RightEmpty);
lcd.createChar(3, AnyFull);
lcd.createChar(4, Divide);
// Load the loading screen if we want to:
if (startLoadingScreen = true) {
LoadingScreen();
}
// Define the button pins:
pinMode(Left, INPUT_PULLUP);
pinMode(Right, INPUT_PULLUP);
// Display the Calculator interface:
lcd.setCursor(5, 1);
lcd.print("Calculator");
lcd.setCursor(2, 3);
lcd.print("+");
lcd.setCursor(6, 3);
lcd.print("-");
lcd.setCursor(9, 3);
lcd.print("x");
lcd.setCursor(13, 3);
lcd.write(4);
lcd.setCursor(17, 3);
lcd.print("^");
lcd.setCursor(2, 3);
lcd.blink();
}
--265 lines later--
for (int i = 0; i < 16; i++) {
if (i >= 9 and opDigits[i] != 0) {
lcd.clear();
lcd.home();
lcd.print("An Error Occurred:");
lcd.setCursor(0, 2);
lcd.print("opDigits.length()>9");
delay(10000);
setup(false);
}
opNumber += startDigits[i];
}
OperationOutput = startNumber + opNumber;
if (OperationOutput > 18446744073709551615) {
lcd.clear();
lcd.home();
lcd.print("An Error Occurred:");
lcd.setCursor(0, 2);
lcd.print("OperationOutput>");
lcd.setCursor(0, 3);
lcd.print("18446744073709551615");
delay(10000);
setup(false);
}
lcd.setCursor((10 - (int64String(OperationOutput).length() / 2)), 2);
lcd.print(int64String(OperationOutput));
lcd.setCursor(0, 3);
while (digitalRead(Left) == HIGH and digitalRead(Right) == HIGH) {
lcd.print("Press A Button To Ex");
delay(1000);
lcd.setCursor(0, 3);
lcd.print("ress A Button To Exi");
delay(1000);
lcd.setCursor(0, 3);
lcd.print("ess A Button To Exit");
delay(1000);
lcd.setCursor(0, 3);
}
setup(false);
}
inOperation = false;
}
Note that this is my first forum post, I have never posted before!
Files:
Calculator.ino (9.15 KB)
CustomChars.h (553 Bytes)