#include #include #include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Reset pin not used with the XIAO RP2040, set to -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1, 1700000UL, 1700000UL); void setup() { // Initialize the display if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { for(;;); // Don’t proceed, loop forever if not found } display.clearDisplay(); // Turn on 50 pixels at random // int pixels = round(SCREEN_WIDTH * SCREEN_HEIGHT/10); // while (pixels > 0){ // int x = random(SCREEN_WIDTH); // int y = random(SCREEN_HEIGHT); // display.drawPixel(x, y, SSD1306_WHITE); // pixels -= 1; // } // Send buffer to display // display.display(); } void loop() { display.clearDisplay(); int pixels = round(SCREEN_WIDTH * SCREEN_HEIGHT/10); while (pixels > 0){ int x = random(SCREEN_WIDTH); int y = random(SCREEN_HEIGHT); display.drawPixel(x, y, SSD1306_WHITE); pixels -= 1; } display.display(); delay(1000); }