Advertisement
pleasedontcode

**OLED Display** rev_06

May 26th, 2025
439
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: **OLED Display**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-05-26 16:28:07
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* generate the code for display hello on oled screen */
  21.     /* by using arduino and bluetooth */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Wire.h>
  28. #include <Adafruit_SSD1306.h>   //https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git
  29. #include <U8g2_for_Adafruit_GFX.h>  //https://github.com/olikraus/U8g2_for_Adafruit_GFX
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF I2C PINS *****/
  36. const uint8_t myDisplay_SSD1306OledDisplay_I2C_PIN_SDA_A4       = A4;
  37. const uint8_t myDisplay_SSD1306OledDisplay_I2C_PIN_SCL_A5       = A5;
  38. const uint8_t myDisplay_SSD1306OledDisplay_I2C_SLAVE_ADDRESS        = 60;
  39.  
  40. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  41. // Create an instance of the OLED display
  42. Adafruit_SSD1306 display(128, 32, &Wire, -1); // Width, Height, Wire, Reset pin
  43.  
  44. void setup(void)
  45. {
  46.     // Initialize the display
  47.     display.begin(SSD1306_SWITCHCAPVCC, myDisplay_SSD1306OledDisplay_I2C_SLAVE_ADDRESS);
  48.     display.clearDisplay(); // Clear the buffer
  49.  
  50.     // Display "Hello" on the OLED screen
  51.     display.setTextSize(1);      // Normal 1:1 pixel scale
  52.     display.setTextColor(SSD1306_WHITE); // Draw white text
  53.     display.setCursor(0, 0);     // Start at top-left corner
  54.     display.println("Hello");      // Display the text
  55.     display.display();            // Show the display buffer on the screen
  56. }
  57.  
  58. void loop(void)
  59. {
  60.     // put your main code here, to run repeatedly:
  61. }
  62.  
  63. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement