Advertisement
Guest User

Untitled

a guest
Jan 13th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SPI.h>
  2. #include <Wire.h>
  3. #include <Adafruit_GFX.h>
  4. #include <Adafruit_SSD1306.h>
  5.  
  6. int OLED_RESET = 4;
  7. Adafruit_SSD1306 display(OLED_RESET);
  8.  
  9. void setup() {
  10.   Serial.begin(9600);
  11.   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  12.   delay(1000);
  13.   display.clearDisplay();
  14.  
  15.   Serial.print("Display: ");
  16.   Serial.print(display.width());
  17.   Serial.print("x");
  18.   Serial.println(display.height());
  19. }
  20.  
  21. void loop() {
  22.   drawRandomBitmap();
  23. }
  24.  
  25. void  drawRandomBitmap() {
  26.   for (int x = 0; x < display.width(); x++) {
  27.     for (int y = 0; y < display.height(); y++) {
  28.       display.drawPixel(x, y, ((rand() & 0x01) == 0) ? WHITE : BLACK);
  29.     }
  30.   }
  31.   display.display();
  32.   Serial.println("refreshed");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement