ccarman602

OLED Girls Who Code logo

Jun 3rd, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*********************************************************************
  2. This is an example for our Monochrome OLEDs based on SSD1306 drivers
  3.  
  4.   Pick one up today in the adafruit shop!
  5.   ------> http://www.adafruit.com/category/63_98
  6.  
  7. This example is for a 128x64 size display using SPI to communicate
  8. 4 or 5 pins are required to interface
  9.  
  10. Adafruit invests time and resources providing this open source code,
  11. please support Adafruit and open-source hardware by purchasing
  12. products from Adafruit!
  13.  
  14. Written by Limor Fried/Ladyada  for Adafruit Industries.  
  15. BSD license, check license.txt for more information
  16. All text above, and the splash screen must be included in any redistribution
  17. *********************************************************************/
  18.  
  19. #include <SPI.h>
  20. #include <Wire.h>
  21. #include <Adafruit_GFX.h>
  22. #include <Adafruit_SSD1306.h>
  23.  
  24. // If using software SPI (the default case):
  25. #define OLED_MOSI   9
  26. #define OLED_CLK   10
  27. #define OLED_DC    11
  28. #define OLED_CS    12
  29. #define OLED_RESET 13
  30. Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
  31.  
  32. /* Uncomment this block to use hardware SPI
  33. #define OLED_DC     6
  34. #define OLED_CS     7
  35. #define OLED_RESET  8
  36. Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
  37. */
  38.  
  39. #define LOGO_GWC_HEIGHT 32
  40. #define LOGO_GWC_WIDTH  128
  41. const unsigned char logo_gwc_bmp[] PROGMEM = {
  42.   // 'girls_who_code_logo_128x64, 128x64px
  43.   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  44.   0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  45.   0xff, 0xff, 0xff, 0xfe, 0xef, 0xff, 0xff, 0xff, 0xff, 0xf2, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
  46.   0xff, 0xff, 0xff, 0xfe, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff,
  47.   0xff, 0xff, 0xff, 0xfe, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff,
  48.   0xff, 0xff, 0xff, 0xfe, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
  49.   0xff, 0xff, 0xff, 0xfe, 0xef, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
  50.   0xff, 0xf7, 0xff, 0xfe, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  51.   0xff, 0xff, 0xff, 0xfe, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  52.   0xff, 0xff, 0xef, 0xfe, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  53.   0xc0, 0xf7, 0xe0, 0xfe, 0x7f, 0x87, 0xff, 0xcf, 0xbe, 0xf4, 0x7f, 0x0f, 0xff, 0xff, 0xff, 0xff,
  54.   0x3c, 0xe7, 0xee, 0xfe, 0xff, 0x7b, 0xff, 0xaf, 0x3e, 0x13, 0xbe, 0xf6, 0x7f, 0xff, 0xff, 0xff,
  55.   0x7c, 0xc7, 0xde, 0xfc, 0x7c, 0xfb, 0xff, 0x67, 0x3c, 0xf7, 0xbc, 0xf2, 0x7f, 0xff, 0xff, 0xff,
  56.   0x3c, 0xb7, 0xbf, 0x73, 0x3b, 0x73, 0x7f, 0xf6, 0x19, 0xf7, 0xb8, 0xf6, 0x7f, 0xff, 0xff, 0xff,
  57.   0xc6, 0x78, 0xff, 0x8f, 0xcf, 0x8b, 0xff, 0xf9, 0xc7, 0xf7, 0xc7, 0x1e, 0x7f, 0xff, 0xff, 0xff,
  58.   0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff,
  59.   0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff,
  60.   0xf6, 0xf8, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x1e, 0x7f, 0x00, 0x00, 0x00,
  61.   0xec, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xfc,
  62.   0xdc, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xfc,
  63.   0xdc, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0x00, 0x00,
  64.   0xdd, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  65.   0xc9, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  66.   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  67.   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  68.   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  69.   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  70.   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  71.   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0x9f, 0xcf, 0xff, 0xfe, 0x7f, 0x3f, 0xff, 0xff,
  72.   0xff, 0xff, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
  73.   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  74.   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  75. };
  76.  
  77. #define SSD1306_LCDHEIGHT 64
  78. #if (SSD1306_LCDHEIGHT != 64)
  79. #error("Height incorrect, please fix Adafruit_SSD1306.h!");
  80. #endif
  81.  
  82. void setup() {
  83.   Serial.begin(9600);
  84.  
  85.   display.begin(SSD1306_SWITCHCAPVCC);
  86.   display.clearDisplay();
  87. }
  88.  
  89. void loop() {
  90.   // display the Girls Who Code logo!
  91.   display.drawBitmap(0, 0, logo_gwc_bmp, LOGO_GWC_WIDTH, LOGO_GWC_HEIGHT, 1);
  92.   display.display();
  93.  
  94.   // invert the display so that it blinks!
  95.   display.invertDisplay(true);
  96.   delay(1000);
  97.   display.invertDisplay(false);
  98.   delay(1000);
  99. }
Add Comment
Please, Sign In to add comment