// Definição de Bibliotecas
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Definição da resolução do OLED display
#define SCREEN_WIDTH 128 // OLED width, in pixels
#define SCREEN_HEIGHT 64 //
// create an OLED display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// definição dos pinos de ESP32 utilizados
const int botao_func = 14; // variavel aux para gurdar o estado do botão
int b_aux = 0; // variavel aux
const int rele = 26; // pino de ligação do relé
const int RGB_Red = 4; // pino de controlo do componente RED do LED
const int RGB_Green = 5; // pino de controlo do componente Green do LED
const int RGB_Blue = 18; // pino de controlo do componente Blue do LED
const int Sensor_Temp = 2;
int S_I_aux
void setup() {;
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
// Definição do funcionamento para os pinos INPUT/OUTP
pinMode(botao_func, INPUT);
pinMode(rele, OUTPUT);
pinMode(RGB_red, OUTPUT);
pinMode(RGB_Green, OUTPUT);
pinMode(RGB_Blue, OUTPUT);
pinMode(Sensor_Temp, INPUT);
// OLED display initialization /////////////////////////////////////
// initialization OLED display with I2C address 0x3C
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)){
Serial.println(F("failed to start SSD1306 OLED"));
while (1);
}
//////////////////////////////////////////////////////////////////////
oled.clearDisplay(); // Clear Display
oled.setTextSize(2); // set text size
oled.setTextColor(WHITE); // Set text color
oled.setCursor(20, 2); //set position to display (x,y)
oled.println("Mec2225"); // Set text
oled.display(); //display on OLED
delay(2000); // wait two seconds for initializing
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
// Definição do funcionamento para os pinos INPUT/
// OLED display initialization ////////////////////////////////////////
// initialize OLED display with I2C adress 0x3C
//
S_T_aux = analogRead(Sensor_Temp);
///////////////////////////////////////////////////////
oled.clearDisplay(); // Clear Display
oled.setTextSize(2); // set text size
oled.setTextColor(WHITE); // Set text color
oled.setCursor(20, 2); // set position to display (x,y)
oled.print("Ssit ON ");
oled.setCursor(20, 30); // set position to display (x,y)
oled.print("S: ");
oled.println(S_T_aux); // set text
oled.display();
// Ativar LED RGB com cor verde
Serial.println("Verde");
//digitalWrite(RGB_Red, LOW)
//digitalWrite()
();
}
else
{
{
// put your main code here, to run repeatealy
b_aux = digitalRead(botao_func)
digitalWrite(RGB_Green, LOW);
digitalWrite(RGB_Blue, LOW);
}
}