Created
April 13, 2025 23:10
-
-
Save johnaboxall/e85bc9c64b0cc4d0a83fa5be1febc5c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <U8g2lib.h> | |
#include <Wire.h> | |
void TCA9548A(uint8_t bus) | |
{ | |
Wire.beginTransmission(0x70); // TCA9548A address is 0x70 | |
Wire.write(1 << bus); // send byte to select bus | |
Wire.endTransmission(); | |
} | |
U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); | |
void setup() | |
{ | |
Wire.begin(); | |
u8g2.begin(); | |
} | |
void loop() | |
{ | |
TCA9548A(0); // tell the TCA9548A we want to use I2C bus number zero (to talk to the OLED) | |
// use the OLED as normal | |
for (int a = 999; a >= 0; --a) | |
{ | |
u8g2.clearBuffer(); // clear the internal memory | |
u8g2.setFont(u8g2_font_inb24_mr ); // choose a suitable font | |
u8g2.setCursor(0, 24); | |
u8g2.print(a); | |
a = a - 47; | |
u8g2.sendBuffer(); // transfer internal memory to the display | |
delay(100); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment