//INCLUIMOS LIBRERIA
#include <Adafruit_SH110X.h> //para la pantalla
#include <Wire.h> //para trabajar con esp32
//variables y objetos
const byte PIN_LED = 14; //MAYUSCULA XQ ES una CTE
Adafruit_SH1106G display (128, 64, &Wire, -1);//clase que me da la libreria para el objeto que implemento - el () llama al constructor
//prototipos/declaraciones de funciones
void escribirPantalla(string texto); //funcion para mostrar texto en la pantalla
void setup() { //se ejecuta una sola vez cuando lanzo el script
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(PIN_LED; OUTPUT);
display.begin(0x3c, true); //define un esclavo, por defecto en la direccion de memoria 0x3c
display.setTextSize(1); //tamano del texto -> 1px
display.setTextColor(SH110X_WHITE); //color del texto
escribirPantalla("HOLA UTN")
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
string aux = " ";
while Serial.available(){
aux += (char)Serial.read(); //leo cada byte y lo convierte en un caracter, y lo concatena para conformar el texto a mostrar
if(aux == "LUZ_ON"){
digitalWrite(PIN_LED, HIGH);
escribirPantalla("DISPOSITIVO ON")
}else if(aux == "LUZ_OFF"){
digitalWrite(PIN_LED, LOW);
digitalWrite("DISPOSITIVO OFF");
}
}
}
delay(100); // this speeds up the simulation
}
//implementacion de las funciones
void escribirPantalla(string texto){
display.clearDisplay();
display.setCursor(0,0);
display.println(texto);
display.display();
}