Advertisement
Guest User

Untitled

a guest
Mar 30th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <Adafruit_GFX.h>
  3. #include <Adafruit_SSD1306.h>
  4.  
  5. #define SCRN_WIDTH 128
  6. #define SCRN_HEIGHT 64
  7. #define OLED_RESET -1
  8. uint32_t I2C_clock = 1000000;
  9.  
  10. Adafruit_SSD1306 display(SCRN_WIDTH, SCRN_HEIGHT, &Wire, OLED_RESET, I2C_clock, I2C_clock);
  11.  
  12. uint32_t thisMicros = 0;
  13. uint32_t lastMicros = 0;
  14.  
  15. void setup()   {
  16.     Wire.begin();
  17.     Wire.setClock(I2C_clock);
  18.     display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  19.     display.display();
  20.     display.clearDisplay();
  21.     display.setTextSize(1);
  22.     display.setTextColor(WHITE);
  23. }
  24.  
  25. void loop()
  26. {
  27.     thisMicros = micros();
  28.     display.clearDisplay();
  29.     display.setCursor(0,0);
  30.     display.print(thisMicros - lastMicros);
  31.     display.display();
  32.     lastMicros = thisMicros;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement