Guest User

Untitled

a guest
Jun 17th, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <OLED_I2C.h>
  2.  
  3. #define WIDTH 128
  4. #define HEIGHT 44
  5.  
  6. OLED myOLED(A4, A5, A4);
  7.  
  8. byte pixel[704];
  9.  
  10. void setup() {
  11.  
  12. myOLED.begin();
  13.  
  14. for (int i = 0; i < (WIDTH * HEIGHT) / sizeof(byte); i++) {
  15.  
  16. pixel[i] = random(0,256);
  17.  
  18. }
  19. }
  20.  
  21. void loop() {
  22.  
  23. myOLED.clrScr();
  24.  
  25. for (int i = 0; i < WIDTH * HEIGHT; i++) {
  26.  
  27. if ( ( pixel[ (int)floor(i / 8) ] ) & ( 128 >> (i % 8 ) ) ) {
  28. myOLED.setPixel(i % WIDTH, (int)floor(i / WIDTH) );
  29. }
  30. }
  31.  
  32. myOLED.update();
  33. delay(500);
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment