ccarman602

KGC OLED Scrolling Text

Jun 3rd, 2020
160
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.  
  33. void setup()   {                
  34.   Serial.begin(9600);
  35.  
  36.   // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  37.   display.begin(SSD1306_SWITCHCAPVCC);
  38.   display.clearDisplay();
  39.   // init done
  40. }
  41.  
  42. void loop() {
  43.   // draw scrolling text
  44.   testscrolltext();
  45.   delay(2000);
  46.   display.clearDisplay();
  47. }
  48.  
  49. void testscrolltext(void) {
  50.   display.setTextSize(2);
  51.   display.setTextColor(WHITE);
  52.   display.setCursor(10,0);
  53.   display.clearDisplay();
  54.   display.println("Girl");
  55.   display.println("Coders");
  56.   display.display();
  57.  
  58.   display.startscrollright(0x00, 0x0F);
  59.   delay(2000);
  60.   display.stopscroll();
  61.   delay(1000);
  62.   display.startscrollleft(0x00, 0x0F);
  63.   delay(2000);
  64.   display.stopscroll();
  65.   delay(1000);    
  66.   display.startscrolldiagright(0x00, 0x07);
  67.   delay(2000);
  68.   display.startscrolldiagleft(0x00, 0x07);
  69.   delay(2000);
  70.   display.stopscroll();
  71. }
Advertisement
Add Comment
Please, Sign In to add comment