

Auf dem ⇒OLED-Display wird eine Stoppuhr als Startsymbol angezeigt, ein Druck auf den Taster startet den Countdown. Eine Zielflagge zeigt das Ende des Countdowns an.
So sieht es aus:
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() | ![]() |

Benötigte Bauteile:
- Taster
- OLED-Display
- Leitungsdrähte
Benötigte Bibliotheken:
![]() | ![]() |
oder: Sketch -> Bibliothek einbinden -> Bibliotheken verwalten

⇒Funktionen der Bibilothek u8g2
Binde die benötigten Bibliotheken ein und definiere die Variablen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include “U8g2lib.h” #include “Bounce2.h” // 1,3 Zoll SH1106 // U8G2_SH1106_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE); // 0,96 Zoll SSD1306 U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE); // Bildschirmgröße int BildschirmBreite = oled.getDisplayWidth(); int BildschirmHoehe = oled.getDisplayHeight(); int TASTER = 7; // Stoppuhr als Objekt der Bibliothek Bounce Bounce StoppUhr = Bounce(); |
Die xbm-Bilder:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | // Bild Stoppuhr #define StoppuhrBreite 50 #define StoppuhrHoehe 56 static unsigned char Stoppuhr[] = { 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x80, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x04, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x01, 0x01, 0x00, 0x00, 0x1c, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x70, 0x00, 0x00, 0x02, 0x00, 0x38, 0x00, 0x30, 0x00, 0x00, 0x02, 0x00, 0x70, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x98, 0x00, 0x00, 0x02, 0x00, 0xe2, 0x00, 0x1c, 0x00, 0x00, 0x03, 0x00, 0xc0, 0x00, 0x1c, 0x00, 0x00, 0x02, 0x00, 0xc0, 0x00, 0x0c, 0x00, 0x00, 0x03, 0x00, 0xc0, 0x01, 0x0e, 0x00, 0x00, 0x03, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x00, 0x07, 0x00, 0x80, 0x01, 0x06, 0x00, 0x00, 0x07, 0x00, 0x80, 0x03, 0x06, 0x00, 0x00, 0x07, 0x00, 0x80, 0x01, 0x06, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x03, 0x06, 0x00, 0x80, 0x07, 0x00, 0x80, 0x01, 0x96, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x03, 0x06, 0x00, 0x00, 0x1f, 0x00, 0x80, 0x01, 0x06, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x03, 0x06, 0x00, 0x00, 0xf8, 0x00, 0x80, 0x03, 0x06, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x0e, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x0e, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x0e, 0x80, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x18, 0xc1, 0x00, 0x1c, 0x04, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x80, 0x87, 0x00, 0x02, 0x08, 0x07, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x3c, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x78, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xc0, 0x7f, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Bild Zielflagge #define ZielBreite 50 #define ZielHoehe 53 static unsigned char Zielflagge[] = { 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xff, 0x03, 0xfe, 0x7f, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x02, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x02, 0x06, 0x44, 0x00, 0x00, 0x54, 0xd5, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x01, 0x00, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03 }; |
Der setup-Teil. Beachte die Kommentare.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | void setup() { StoppUhr.attach(TASTER); // Display starten oled.begin(); // Kontrast maximal 255 oled.setContrast(200); pinMode(TASTER, INPUT_PULLUP); // Stoppuhr anzeigen oled.firstPage(); do { oled.drawXBM(40, 1, StoppuhrBreite, StoppuhrHoehe, Stoppuhr); } while (oled.nextPage()); } |
Der loop-Teil. Beachte die Kommentare.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | void loop() { // Farbe weiß oled.setDrawColor(1); // Beginn des Countdowns int Nummer = 9; int TasterLesen = digitalRead(TASTER); // Taster gedrückt if (StoppUhr.update()) { if (StoppUhr.read() == LOW) { oled.setFont(u8g2_font_logisoso62_tn); while (Nummer > 0) { oled.firstPage(); do { oled.setFontDirection(0); oled.setCursor(50, BildschirmHoehe); oled.print(Nummer); } while (oled.nextPage()); delay(1000); Nummer –; } // Ziel anzeigen oled.firstPage(); do { oled.drawXBM(40, 5, ZielBreite, ZielHoehe, Zielflagge); } while (oled.nextPage()); } } } |
Verwandte Anleitungen:
Letzte Aktualisierung:



















