Advertisement
alberane

SSD1306

May 23rd, 2022
655
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Arduino.h>
  2. #include <U8g2lib.h>
  3.  
  4. #ifdef U8X8_HAVE_HW_SPI
  5. #include <SPI.h>
  6. #endif
  7. #ifdef U8X8_HAVE_HW_I2C
  8. #include <Wire.h>
  9. #endif
  10.  
  11. U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(
  12.   U8G2_R0,
  13.   /* clock=*/ 13,
  14.   /* data=*/ 11,
  15.   /* cs=*/ 10,
  16.   /* dc=*/ 9,
  17.   /* reset=*/ 8);
  18.  
  19. const PROGMEM uint8_t heartImage[8] =
  20. {
  21.     0B00001110,
  22.     0B00011111,
  23.     0B00111111,
  24.     0B01111110,
  25.     0B01111110,
  26.     0B00111101,
  27.     0B00011001,
  28.     0B00001110
  29. };
  30.  
  31. void setup(void) {
  32.   u8g2.begin();
  33. }
  34.  
  35. void loop(void) {
  36.   u8g2.clearBuffer();                  
  37.   u8g2.setFont(u8g2_font_ncenB08_tr);  
  38.   u8g2.drawStr(20,25,"Opa!!! Agora foi!"); 
  39.   u8g2.drawFrame(3,3,120,60);
  40.  
  41.   u8g2.sendBuffer();                   
  42.   delay(500);  
  43. }
  44.  
Advertisement
RAW Paste Data Copied
Advertisement