/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: OLED Hello - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-10-19 21:02:45 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* just check that the display works in a espduino 32 */ /* hw 707 (almost the same that d1 r32) whit a simple */ /* code. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include // https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git #include // https://github.com/olikraus/U8g2_for_Adafruit_GFX /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF I2C PINS *****/ const uint8_t SSD1306_I2C_PIN_SDA = 21; // SDA pin const uint8_t SSD1306_I2C_PIN_SCL = 22; // SCL pin const uint8_t SSD1306_I2C_SLAVE_ADDRESS = 60; // I2C address /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/ Adafruit_SSD1306 display(SSD1306_I2C_SLAVE_ADDRESS); // Initialize the display object U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx; // Initialize U8g2 for Adafruit GFX void setup(void) { // Initialize the display display.begin(SSD1306_SWITCHCAPVCC, SSD1306_I2C_SLAVE_ADDRESS); // Start the display display.clearDisplay(); // Clear the display buffer // Connect U8g2 procedures to Adafruit GFX u8g2_for_adafruit_gfx.begin(display); // Initialize U8g2 with the display object // Example to set font and display text u8g2_for_adafruit_gfx.setFontMode(1); // Use U8g2 transparent mode u8g2_for_adafruit_gfx.setFontDirection(0); // Left to right u8g2_for_adafruit_gfx.setForegroundColor(WHITE); // Set text color to white u8g2_for_adafruit_gfx.setFont(u8g2_font_helvR14_tf); // Select a font u8g2_for_adafruit_gfx.setCursor(0, 20); // Set cursor position u8g2_for_adafruit_gfx.print(F("Hello World")); // Print text display.display(); // Make everything visible delay(2000); // Delay for 2 seconds } void loop(void) { // Main code to run repeatedly display.clearDisplay(); // Clear the display buffer u8g2_for_adafruit_gfx.setCursor(0, 20); // Set cursor position u8g2_for_adafruit_gfx.print(F("Hello World")); // Print text display.display(); // Make everything visible delay(2000); // Delay for 2 seconds }