/* OLED Ansteuerung Test 13032026 This example code is in the public domain. */ #include #include #include #define SCREEN_WIDTH 128 // Breite in Pixel #define SCREEN_HEIGHT 64 // Höhe in Pixel // OLED Display Instanz erstellen (I2C) // Reset Pin wird hier nicht benötigt, daher -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); int zaehler = 0; void setup() { // Initialisierung mit I2C Adresse 0x3C (die meisten Displays) if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { for(;;); // Bei Fehler unendlich warten } display.clearDisplay(); // Displaybuffer leeren display.setTextSize(2); // Textgröße display.setTextColor(SSD1306_WHITE); // Textfarbe (weiß) } void loop() { display.clearDisplay(); // Erste Zeile display.setCursor(0,0); display.println("Analogwert "); // zweite Zeile mit Zähler display.setCursor(0,15); display.print("Zeit: "); display.print(zaehler); // dritte Zeile Messwert 1 display.setCursor(0,30); display.print("U1:"); // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); display.print(voltage);//analogRead(A0)); // vierte Zeile Messwert 2 display.setCursor(0,45); display.print("U2:"); // read the input on analog pin 0: int sensor1Value = analogRead(A1); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage2 = sensor1Value * (5.0 / 1023.0); display.print(voltage2);//(analogRead(A1)); display.display(); // Daten auf Display anzeigen zaehler++; delay(1000); // 1 Sekunde warten }