#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
/*
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin (not used)
// Initialize OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Bitmaps (replace these arrays with actual bitmap data)
const unsigned char epd_bitmap_stop[] PROGMEM = {
// Add bitmap data here (stop image)
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff,
0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff,
0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff,
0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xfc, 0x00, 0x3f, 0xfc, 0x03, 0xff, 0xff, 0xe0, 0x07, 0xff, 0x80, 0x0f, 0xff, 0xfc, 0x00, 0x3f,
0xfc, 0x00, 0xff, 0xff, 0x83, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0x00, 0x3f,
0xfc, 0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00, 0xfe, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x07, 0xc0, 0x07, 0xe0, 0x03, 0xf0, 0x01, 0xfc, 0x00, 0xfe, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x0f, 0xc0, 0x07, 0xe0, 0x03, 0xf0, 0x00, 0xfc, 0x00, 0xfc, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x0f, 0xe0, 0x0f, 0xe0, 0x03, 0xf0, 0x00, 0xfe, 0x01, 0xfc, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x07, 0xf0, 0x1f, 0xc0, 0x03, 0xf0, 0x00, 0x7f, 0x03, 0xf8, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x03, 0xff, 0xff, 0x80, 0x03, 0xf0, 0x00, 0x3f, 0xff, 0xf0, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x01, 0xff, 0xff, 0x00, 0x03, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x0f, 0xe0, 0x00, 0x00, 0x3f,
0xfc, 0x00, 0x7f, 0xfc, 0x00, 0x03, 0xf0, 0x00, 0x07, 0xff, 0x80, 0x0f, 0xc0, 0x00, 0x00, 0x3f,
0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff,
0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,
0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff,
0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff,
0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff,
0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff,
0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff,
0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char epd_bitmap_wait[] PROGMEM = {
// Add bitmap data here (wait image)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x3C, 0x00,
0x00, 0x42, 0x81, 0x81, 0x81, 0x42, 0x00, 0x00,
0x00, 0x42, 0x81, 0xBD, 0x81, 0x42, 0x00, 0x00,
0x00, 0x42, 0x81, 0x81, 0x81, 0x42, 0x00, 0x00,
0x00, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x3C, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char epd_bitmap_pedestrian[] PROGMEM = {
0x00, 0xFF, 0xFF, 0x00, 0x00, // Head
0xFF, 0xFF, 0xFF, 0xFF, 0x00, // Body
0x00, 0x00, 0xFF, 0x00, 0xFF, // Body
0xFF, 0x00, 0xFF, 0x00, 0xFF, // Arms
0x00, 0xFF, 0xFF, 0x00, 0x00, // Waist
0xFF, 0x00, 0x00, 0xFF, 0xFF, // Legs
0xFF, 0xFF, 0xFF, 0x00, 0x00, // Ground line
};
// Enum to represent display state
enum DisplayState {
STOP, PEDES,
WAIT
};
// Function to show the appropriate bitmap based on the state
void showBitmap(DisplayState state) {
display.clearDisplay(); // Clear the screen
switch (state) {
case STOP:
display.drawBitmap(0, 0, epd_bitmap_stop, SCREEN_WIDTH, SCREEN_HEIGHT, WHITE);
display.setCursor(0, 56); // Position the text
display.print("STOP");
break;
case WAIT:
display.drawBitmap(0, 0, epd_bitmap_wait, SCREEN_WIDTH, SCREEN_HEIGHT, WHITE);
display.setCursor(0, 0); // Position the text
display.print("WAIT");
break;
case PEDES:
display.drawBitmap(0, 0, epd_bitmap_pedestrian, SCREEN_WIDTH, SCREEN_HEIGHT, WHITE);
display.setCursor(0, 56); // Position the text
display.print("PEDES");
break;
default:
break;
}
display.display(); // Render the image
}
// Setup function to initialize the display and serial communication
void setup() {
// Initialize the OLED display
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(WHITE);
// Initialize serial communication
Serial.begin(9600);
Serial.println("Enter 'STOP' or 'WAIT' to display the respective symbol:");
}
// Loop function to continuously listen for user input from the serial monitor
void loop() {
if (Serial.available() > 0) {
String input = Serial.readStringUntil('\n'); // Read input from serial monitor
input.trim(); // Remove any extra whitespace
if (input.equalsIgnoreCase("STOP")) {
showBitmap(STOP);
}
else if (input.equalsIgnoreCase("WAIT")) {
showBitmap(WAIT);
}
else if (input.equalsIgnoreCase("PEDES")) {
showBitmap(PEDES);
}
else if (input.equalsIgnoreCase("CLEAR")) {
display.clearDisplay(); // Clear the display
display.display(); // Update the display to show it is cleared
Serial.println("Screen cleared. Enter the next symbol:");
}
else {
Serial.println("Invalid input. Please enter 'STOP', 'WAIT', or 'CLEAR'.");
}
}
}
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define the OLED display parameters
#define SCREEN_WIDTH 128 // Width of the OLED display
#define SCREEN_HEIGHT 64 // Height of the OLED display
// Create the display object
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // -1 for reset pin not used
void setup() {
// Initialize the OLED display
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for the OLED
display.clearDisplay(); // Clear the display
display.setTextSize(1); // Set text size
display.setTextColor(SSD1306_WHITE); // Set text color
display.setCursor(0, 0); // Set cursor to top-left
display.println("⏳ Waiting..."); // Print waiting emoji
display.println("🛑 Stop!"); // Print stop emoji
display.display(); // Show the text on the display
}
void loop() {
// Your main code here (if needed)
}