Advertisement
pleasedontcode

**Display Hello** rev_08

Feb 15th, 2025
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Display Hello**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-02-15 17:50:22
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Display "Hello, World!" on the SSD1306 OLED using */
  21.     /* I2C communication with SDA on pin D21 and SCL on */
  22.     /* pin D22, ensuring proper initialization of the */
  23.     /* Adafruit SSD1306 library. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <Wire.h>
  30. #include <Adafruit_SSD1306.h>   //https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git
  31. #include <U8g2_for_Adafruit_GFX.h>  //https://github.com/olikraus/U8g2_for_Adafruit_GFX
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF I2C PINS *****/
  38. const uint8_t display_SSD1306OledDisplay_I2C_PIN_SDA_D21        = 21;
  39. const uint8_t display_SSD1306OledDisplay_I2C_PIN_SCL_D22        = 22;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. // Create an instance of the Adafruit_SSD1306 class
  43. Adafruit_SSD1306 display(128, 32, &Wire); // Initialize with width, height, and Wire instance
  44.  
  45. void setup(void)
  46. {
  47.     // Initialize the display
  48.     if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Check if the display is connected
  49.         for(;;); // Don't proceed, loop forever
  50.     }
  51.  
  52.     display.clearDisplay(); // Clear the buffer
  53.     display.setTextSize(1); // Set text size
  54.     display.setTextColor(SSD1306_WHITE); // Set text color
  55.     display.setCursor(0, 0); // Set cursor position
  56.     display.print("Hello, World!"); // Print text
  57.     display.display(); // Display the buffer on the screen
  58. }
  59.  
  60. void loop(void)
  61. {
  62.     // put your main code here, to run repeatedly:
  63. }
  64.  
  65. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement