#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // Ancho de la pantalla OLED en píxeles
#define SCREEN_HEIGHT 64 // Altura de la pantalla OLED en píxeles
#define OLED_RESET -1 // El pin de reset del display OLED
// Inicializa el objeto de la pantalla OLED
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Define la imagen en forma de array de bytes (bitmap)
const unsigned char PROGMEM imagen[] = {
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0xfe, 0xff, 0x81, 0xf8, 0xf1, 0xbf, 0xf0, 0x7f, 0xfe, 0x0c, 0xff, 0x87, 0xf8, 0xfe, 0x01,
0x81, 0xfe, 0xff, 0xc3, 0xfc, 0xf9, 0xbf, 0xf0, 0x7f, 0xef, 0x0d, 0xff, 0xc7, 0xf9, 0xff, 0x81,
0x81, 0xc0, 0xe0, 0xe7, 0x86, 0xf9, 0x87, 0x80, 0x07, 0x07, 0x99, 0xe1, 0xc7, 0x01, 0xe0, 0x01,
0x81, 0xfe, 0xff, 0xc7, 0x06, 0xfd, 0x87, 0x80, 0x07, 0x03, 0xf1, 0xff, 0xc7, 0xf9, 0xff, 0x01,
0x81, 0xfe, 0xff, 0x87, 0x06, 0xdf, 0x87, 0x80, 0x07, 0x01, 0xe1, 0xff, 0x87, 0xf8, 0xff, 0x81,
0x81, 0xc0, 0xfc, 0x17, 0x86, 0xcf, 0x87, 0x80, 0x07, 0x01, 0xe1, 0xfc, 0x37, 0x00, 0x07, 0x81,
0x81, 0xc0, 0xef, 0xf3, 0xfc, 0xcf, 0x87, 0x80, 0x07, 0x01, 0xe1, 0xef, 0xf7, 0xf9, 0xc3, 0x81,
0x81, 0xc0, 0xe3, 0xe1, 0xf8, 0xc7, 0x87, 0x80, 0x07, 0x01, 0xe1, 0xe7, 0xe7, 0xfc, 0xff, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x3f, 0xe1, 0xff, 0x0f, 0x0f, 0xf8, 0x03, 0xff, 0xf0, 0x6f, 0xfc, 0x3f, 0xc7, 0xf0, 0x01,
0x80, 0x3f, 0xf1, 0xff, 0x1f, 0x0f, 0xfe, 0x03, 0xff, 0x78, 0xef, 0xfe, 0x3f, 0xcf, 0xf8, 0x01,
0x80, 0x38, 0x79, 0xc0, 0x1f, 0x8e, 0x0e, 0x00, 0x38, 0x3c, 0xcf, 0x0e, 0x38, 0x0f, 0x00, 0x01,
0x80, 0x3f, 0xf1, 0xfe, 0x33, 0x8f, 0xfe, 0x00, 0x38, 0x1d, 0x8f, 0xfe, 0x3f, 0xcf, 0xf8, 0x01,
0x80, 0x3f, 0xe1, 0xfe, 0x33, 0xcf, 0xfc, 0x00, 0x38, 0x1f, 0x0f, 0xfc, 0x3f, 0xc7, 0xfc, 0x01,
0x80, 0x3f, 0x05, 0xc0, 0x7f, 0xcf, 0xe1, 0x00, 0x38, 0x0f, 0x0f, 0xe1, 0xb8, 0x00, 0x3c, 0x01,
0x80, 0x3b, 0xfd, 0xff, 0x61, 0xee, 0xff, 0x00, 0x38, 0x0e, 0x0f, 0x7f, 0xbf, 0xce, 0x1c, 0x01,
0x80, 0x39, 0xf9, 0xff, 0x61, 0xee, 0x3e, 0x00, 0x38, 0x0e, 0x0f, 0x3f, 0x3f, 0xc7, 0xf8, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc
// Aquí va tu imagen en formato bitmap
// Puedes usar herramientas en línea para convertir una imagen a formato bitmap
};
const int sensorPin = A0; // Pin analógico al que está conectado el sensor de presión
const int sensorPin2 = A1; // Segundo pin analógico al que está conectado el sensor de presión
// Definir los bytes de la imagen (debes convertir tu imagen a un array de bytes)
const unsigned char PROGMEM myImage[] = {
// Aquí va la información de la imagen en formato byte
};
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Inicializar la pantalla OLED
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.display();
delay(2000); // Esperar 2 segundos
display.clearDisplay(); // Limpiar la pantalla OLED
}
void loop() {
// Mostrar la imagen personalizada
display.clearDisplay();
display.drawBitmap(0, 0, imagen, SCREEN_WIDTH, SCREEN_HEIGHT, WHITE);
// Mostrar valores del sensor de presión
int sensorValue = analogRead(sensorPin); // Leer el valor del sensor de presión
float psiValue = map(sensorValue, 0, 1023, 0, 1000); // Mapear el valor leído a PSI
display.setTextSize(1.8); // Tamaño del texto
display.setTextColor(SSD1306_WHITE); // Color del texto
display.setCursor(40 , 17); // Posición del cursor
display.print(psiValue);
display.print(" PSI");
int sensorValue2 = analogRead(sensorPin2); // Leer el valor del segundo sensor de presión
float psiValue2 = map(sensorValue2, 0, 1023, 0, 1000); // Mapear el valor leído a PSI
display.setCursor(40 , 51); // Posición del cursor para el segundo sensor
display.print(psiValue2);
display.print(" PSI");
display.display(); // Mostrar en pantalla
display.display(); // Mostrar en pantalla
delay(1000); // Esperar 1 segundo antes de la siguiente lectura
}