Advertisement
pleasedontcode

SSD1306 Display rev_01

Apr 1st, 2024
72
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: SSD1306 Display
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-04-01 10:46:18
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* statemachine */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Wire.h>
  25. #include <Adafruit_SSD1306.h>
  26.  
  27. /*
  28.  * /****** FUNCTION PROTOTYPES *****/
  29.  
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /*
  34.  * /*!< Definitions of I2C pins */
  35. const uint8_t DISPLAY_PIN_SDA = 21; // connected to SDA pin on the ESP32
  36. const uint8_t DISPLAY_PIN_SCL = 22; // connected to SCL pin on the ESP32
  37. const uint8_t DISPLAY_SLAVE_ADDRESS = 0x3C; // I2C address of the display
  38.  
  39. Adafruit_SSD1306 display(DISPLAY_PIN_SDA, DISPLAY_PIN_SCL);
  40.  
  41. /*
  42.  * Initialize the I2C communication with the display and perform setup tasks
  43. */
  44. void setup(void)
  45. {
  46.     Wire.begin(DISPLAY_PIN_SDA, DISPLAY_PIN_SCL);
  47.    
  48.     display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_SLAVE_ADDRESS);
  49.     display.clearDisplay();        
  50.     display.dim(0);  
  51.     display.setTextColor(SSD1306_WHITE);
  52.     display.setRotation(1);
  53.  
  54.     /* INSERT LCD CONFIGURATION */
  55.  
  56.     display.println("Setup Process...");
  57.     display.display();
  58.     delay(2000);
  59.     display.clearDisplay();
  60. }
  61.  
  62. /*
  63.  * Main loop of the program
  64. */
  65. void loop(void)
  66. {
  67.     display.setCursor(0, 0);
  68.     display.clearDisplay();
  69.     display.display();
  70.  
  71.     display.println("Loop!");
  72.     display.display();
  73.    
  74.     delay(1000);
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement