I am trying to separate the display code i2c
from another file as there are many lines in main.cpp
I'm using PlatformIO
, the class is inside a folder that you create called Class
This is my main
#include <Arduino.h>
#include "Class/Display.h"
Display lcd;
void setup() {
lcd.bienvenida();
}
void loop() {
//
}
And this is my Display class
#ifndef Display_h
#define Display_h
#include <Arduino.h>
#include <LiquidCrystal_I2C.h>
class Display;
class Display {
private:
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2);
public:
Display();
void bienvenida();
};
Display::Display() {
lcd.init();
lcd.backlight();
};
void Display::bienvenida() {
lcd.clear();
lcd.setCursor(4,0);
lcd.print("HOLA");
lcd.setCursor(3,1);
lcd.print("MUNDO");
};
#endif
But it does not work, if I put all the code of the class in the main, then if it works fine but not from class.
I know very little about c ++ and I'm starting to see Arduino
Any solution?