/* Claude EMERY 18/03/2026
Texte d'affichage maximum d'un Oled 0.96 128x64 pixels - Adresse 0x3c
Affichage dans void setup()
Affichage de la chaine de caractères: ("01234567890123456789A
01234567890123456789B
01234567890123456789C
01234567890123456789D
01234567890123456789E
01234567890123456789F
01234567890123456789G
01234567890123456789H
01234567890123456789I")
La derniere ligne 01234567890123456789I ne s'affiche pas sur l'Oled 0.96 128x64 pixels
Alors qu'elle s'affiche dans le moniteur série.
On peut donc dire que l'Oled 0.96 128x64 pixel avec la librairie <Adafruit_SSD1306.h> affiche seulement
21 caractères x 8 lignes
1 caractères s'affiche sur 128/21 = 6,095 pixels
1 caractères s'affiche sur 64/8 = 8 pixels
Affichage dans le void loop()
Affichage ("0123456789-0123456789") - 8 fois
Affichage n° de ligne dans moniteur serie
*/
// Librairies
#include <Wire.h> // Gestion I2C pour Oled SDA/SCL Adresse 0x3c
#include <Adafruit_GFX.h> // Affichage graphique
#include <Adafruit_SSD1306.h> // Driver Oled 0.96" - SSD1306
// Configuration OLED
//#define SCREEN_WIDTH 128 // Largeur 128 pixels
//#define SCREEN_HEIGHT 64 // Hauteur 64 pixels
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // SDA=A4 SCL=A5 - Initialisation Oled 0.96
Adafruit_SSD1306 monOled(128, 64, &Wire, -1);
int i=0; //Variable pour la boucle for
void setup(){
Serial.begin(9600);
// Initialisation de l'écran OLED - Si Oled non detecté = Échec de l'initialisation de l'écran OLED !
if (!monOled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("Échec de l'initialisation de l'écran OLED !");
for (;;); // Boucle sans fin
monOled.display();
monOled.clearDisplay();
}
monOled.clearDisplay(); //Effacement Oled
monOled.setTextColor(WHITE); //Couleur Texte en Blanc
monOled.setCursor(0,0); //Colonne, Ligne
monOled.setTextSize(1,3); //Taille 1
monOled.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
monOled.display(); //Commande d'Affichage
Serial.println("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
delay(2000);
monOled.clearDisplay(); //Effacement Oled
}
void loop(){
for (i = 0; i < 64; i=i+8) { //Boucle de 0 à 64 avec pas de 8
monOled.setCursor(0,i); //Colonne, Ligne
monOled.print("0123456789-0123456789");
monOled.display();
Serial.print("Ligne ");
Serial.println(i); //Affichage n° de ligne dans moniteur série
delay(1000);
}
monOled.clearDisplay();
}