There is the SCl, the data even chipselect, which was not used, is connected and is measured. However, nothing is shown on the display. According to the data sheet, it was connected https://www.mouser.com/datasheet/2/127/oledm128_6e-1388684.pdf for the I2C 0x78 (0x3C). Does anyone know a solution to what it could be that it doesn't work.
#include <Wire.h>
#define OLED_I2C_ADDRESS 0x3C // I2C-Adresse des Displays
int cs = 7;
// the setup routine runs once when you press reset:
void setup() {
pinMode(cs, OUTPUT);
digitalWrite(cs, HIGH); // cs für Display auf 1
delay(2);
digitalWrite(cs, LOW); // cs für Display auf 0
Wire.begin(); // I2C starten
delay(400);
init_OLEDM128(); // OLED initialisieren
digitalWrite(cs, HIGH); // cs für Display auf 1
}
// Befehl an das OLED senden
void send_command(uint8_t command) {
Wire.beginTransmission(OLED_I2C_ADDRESS);
Wire.write(command);
Wire.endTransmission();
}
// Daten an das Display senden (z.B. Textanzeige)
void send_data(uint8_t data) {
Wire.beginTransmission(OLED_I2C_ADDRESS);
Wire.write(data);
Wire.endTransmission();
}
// OLED initialisieren
void init_OLEDM128() {
send_command(0x40); //Set Display start line
send_command(0xA0); //Bottom View no Segment remap
send_command(0xC0); //Bottom View COM scan direction normal
send_command(0xA6); //Display normal (RAM)
send_command(0x81);
send_command(0xFF);
send_command(0xD5);
send_command(0x40); //Clock divider/Oscillator frequency
send_command(0xD9);
send_command(0x44); //Preācharge Period
send_command(0xAF); //Display on
}
// "Hello World!" auf das Display schreiben
void display_text(const char*text) {
for (uint8_t i = 0; text[i] != '\0'; i++) {
send_data(text[i]); // Zeichen senden
}
}
void loop() {
digitalWrite(cs, LOW); // cs für Display auf 0
display_text("Hello");
digitalWrite(cs, HIGH); // cs für Display auf 1
}