I'm using c++ to program an arduino. I am trying to separate each of my main systems into its own c++ and header file. I am using a library for the LCD but I'm having trouble using it. I want to declare it in lcd.h so that I can access it from any other script that wants to print to the LCD.
Upon building, I get this error:
1 2 3
.pioenvs\uno\src\window.cpp.o (symbol from plugin): In function `lcd':
(.text+0x0): multiple definition of `lcd'
.pioenvs\uno\src\lcd.cpp.o (symbol from plugin):(.text+0x0): first defined here
Below are some of my scripts (I have deleted irrelevant sections of the code).
//----LIBRARIES----
#include "lcd.h"
//----IMPLEMENTATIONS----
void InitializeLCD()
{
//initialize lcd for 16 columns and 2 rows
lcd.begin(16, 2);
//inform user that the system is Initializing
lcd.setCursor(0, 0);
lcd.print("Initializing");
delay(3000);
lcd.clear();
}
You are creating an object named lcd in a header. You are then including that header in two different cpp files, so you have two files with the same object being created in them. You are not allowed to create the same object twice in one program.
What should I be doing? When I try declaring it like this: LiquidCrystalSerial lcd;
it tells me there's no matching function for call to 'LiquidCrystalSerial::LiquidCrystalSerial()