Dernière révision : septembre 2023










Projet ESP8266 n° 2

Philippe Notez (philippe.notez@musee-info.fr)





Sommaire

Introduction

L’électronique et l’informatique ont profondément modifié notre société. C’est certainement la révolution industrielle la plus rapide de l’histoire de l’humanité. En effet, l’ordinateur que nous connaissons aujourd’hui était tout simplement inimaginable il y a seulement une cinquantaine d’années. Et avec les Arduino, les ESP8266 ou les Raspberry Pi Pico, l'aventure est loin d'être terminée.

L’auteur ne pourra en aucun cas être tenu responsable des dommages qui résulteraient de l’utilisation des informations publiées sur ce site, sous licence Creative Commons BY-NC-SA. Toute reproduction ou modification d'un document, même partielle, est autorisée à condition que son origine et le nom de l'auteur soient clairement indiqués (BY), qu'il soit utilisé à des fins non commerciales (NC), que son mode de diffusion soit identique au document initial (SA), et que cela ne porte pas atteinte à l’auteur.

Ce document présente un projet utilisant une carte ESP8266, en espérant toujours être le plus clair et précis possible. Malgré tout le soin apporté à la rédaction, l'auteur vous remercie de bien vouloir le contacter si vous relevez la moindre erreur ou omission, et vous souhaite une agréable lecture.

Si vous avez apprécié ce document, vous pouvez faire un don ici. Merci pour votre soutien.


Objectif

Afficher un texte défilant sur des matrices 8 x 8 leds (module MAX7219), via une connexion wifi (maj OTA).


Niveau




Matériel utilisé
  • une carte ESP8266
  • un module horloge temps réel DS3231 (quartz interne : moins de dérive)
  • six modules MAX7219
  • une alimentation stabilisée 5 V - 4 A
  • des câbles Dupont
  • un câble USB pour la liaison avec l'ordinateur

Programme (sketch)

max7219_1.ino
// afficher un texte défilant sur des matrices 8 x 8 leds (module MAX7219),
// via une connexion wifi (maj OTA)

#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
#include <LedControl.h>
#include <Wire.h>

#define nom_wifi "..."
#define mdp_wifi "..."
#define nom_ota "MAX7219"
#define mdp_ota "..."
#define nbr_modules 6

IPAddress ip(192,168,1,55);
IPAddress masque(255,255,255,0);
IPAddress passerelle(192,168,1,1);
IPAddress dns(192,168,1,1);
LedControl module=LedControl(12,15,13,nbr_modules); // DIN, CLK, CS

unsigned char debut=0,texte[256],tab_date[11],tab_heure[9],nbr_car,tab_car[8];

void setup()
  {
  unsigned char num_module;

  WiFi.mode(WIFI_STA);
  WiFi.config(ip,passerelle,masque,dns);
  WiFi.begin(nom_wifi,mdp_wifi);
  while (WiFi.status()!=WL_CONNECTED) delay(100);
  ArduinoOTA.setHostname(nom_ota);
  ArduinoOTA.setPassword(mdp_ota);
  ArduinoOTA.begin();
  for (num_module=0;num_module<nbr_modules;num_module++)
    {
    module.setIntensity(num_module,15); // 0 à 15
    module.shutdown(num_module,false);  // activer le module
    }
  Wire.begin();
  }

void loop()
  {
  int num_module;
  unsigned char index=0;

  ArduinoOTA.handle(); 
  if (debut==0)
    {
    strcpy(texte,"      BIENVENUE AU PETIT MUSEE DE L'INFORMATIQUE. NOUS SOMMES LE ");
    lire_ds3231();
    strcat(texte,tab_date);
    strcat(texte,". IL EST ");
    strcat(texte,tab_heure);
    strcat(texte,". BONNE JOURNEE !");
    nbr_car=strlen(texte);
    }
  for (num_module=nbr_modules-1;num_module>=0;num_module--)
    {
    if (debut+index<nbr_car) init_tab_car(texte[debut+index]);
    else init_tab_car(texte[debut+index-nbr_car]);
    aff_car(num_module);
    index++;
    }
  debut++;
  if (debut==nbr_car) debut=0;
  delay(200);
  }

void aff_car(unsigned char num_module)
  {
  unsigned char lig;

  for (lig=0;lig<8;lig++)
    {
    module.setLed(num_module,0,7-lig,tab_car[lig]&128);
    module.setLed(num_module,1,7-lig,tab_car[lig]&64);
    module.setLed(num_module,2,7-lig,tab_car[lig]&32);
    module.setLed(num_module,3,7-lig,tab_car[lig]&16);
    module.setLed(num_module,4,7-lig,tab_car[lig]&8);
    module.setLed(num_module,5,7-lig,tab_car[lig]&4);
    module.setLed(num_module,6,7-lig,tab_car[lig]&2);
    module.setLed(num_module,7,7-lig,tab_car[lig]&1);
    }
  }

void init_tab_car(unsigned char car)
  {
  switch (car)
    {
    // espace
    case 32 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000000;
      tab_car[2]=B00000000;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // !
    case 33 :
      tab_car[0]=B00010000;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00010000;
      tab_car[4]=B00010000;
      tab_car[5]=B00000000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // "
    case 34 :
      tab_car[0]=B00101000;
      tab_car[1]=B00101000;
      tab_car[2]=B00101000;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // #
    case 35 :
      tab_car[0]=B00101000;
      tab_car[1]=B00101000;
      tab_car[2]=B01111100;
      tab_car[3]=B00101000;
      tab_car[4]=B01111100;
      tab_car[5]=B00101000;
      tab_car[6]=B00101000;
      tab_car[7]=B00000000;
    break;
    // $ (€)
    case 36 :
      tab_car[0]=B00011000;
      tab_car[1]=B00100100;
      tab_car[2]=B01111000;
      tab_car[3]=B00100000;
      tab_car[4]=B01111000;
      tab_car[5]=B00100100;
      tab_car[6]=B00011000;
      tab_car[7]=B00000000;
    break;
    // %
    case 37 :
      tab_car[0]=B00000000;
      tab_car[1]=B01100100;
      tab_car[2]=B01101000;
      tab_car[3]=B00010000;
      tab_car[4]=B00101100;
      tab_car[5]=B01001100;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // &
    case 38 :
      tab_car[0]=B00110000;
      tab_car[1]=B01001000;
      tab_car[2]=B01001000;
      tab_car[3]=B00110000;
      tab_car[4]=B00110100;
      tab_car[5]=B01001000;
      tab_car[6]=B00110100;
      tab_car[7]=B00000000;
    break;
    // '
    case 39 :
      tab_car[0]=B00010000;
      tab_car[1]=B00010000;
      tab_car[2]=B00100000;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // (
    case 40 :
      tab_car[0]=B00001000;
      tab_car[1]=B00010000;
      tab_car[2]=B00100000;
      tab_car[3]=B00100000;
      tab_car[4]=B00100000;
      tab_car[5]=B00010000;
      tab_car[6]=B00001000;
      tab_car[7]=B00000000;
    break;
    // )
    case 41 :
      tab_car[0]=B00100000;
      tab_car[1]=B00010000;
      tab_car[2]=B00001000;
      tab_car[3]=B00001000;
      tab_car[4]=B00001000;
      tab_car[5]=B00010000;
      tab_car[6]=B00100000;
      tab_car[7]=B00000000;
    break;
    // *
    case 42 :
      tab_car[0]=B01010100;
      tab_car[1]=B00111000;
      tab_car[2]=B01111100;
      tab_car[3]=B00111000;
      tab_car[4]=B01010100;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // +
    case 43 :
      tab_car[0]=B00000000;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B01111100;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // -
    case 45 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000000;
      tab_car[2]=B00000000;
      tab_car[3]=B01111100;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // .
    case 46 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000000;
      tab_car[2]=B00000000;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // /
    case 47 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000100;
      tab_car[2]=B00001000;
      tab_car[3]=B00010000;
      tab_car[4]=B00100000;
      tab_car[5]=B01000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // 0
    case 48 :
      tab_car[0]=B00010000;
      tab_car[1]=B00101000;
      tab_car[2]=B01000100;
      tab_car[3]=B01000100;
      tab_car[4]=B01000100;
      tab_car[5]=B00101000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // 1
    case 49 :
      tab_car[0]=B00010000;
      tab_car[1]=B00110000;
      tab_car[2]=B01010000;
      tab_car[3]=B00010000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // 2
    case 50 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B00000100;
      tab_car[3]=B00001000;
      tab_car[4]=B00010000;
      tab_car[5]=B00100000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // 3
    case 51 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B00000100;
      tab_car[3]=B00011000;
      tab_car[4]=B00000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // 4
    case 52 :
      tab_car[0]=B00001000;
      tab_car[1]=B00011000;
      tab_car[2]=B00101000;
      tab_car[3]=B01001000;
      tab_car[4]=B01111100;
      tab_car[5]=B00001000;
      tab_car[6]=B00001000;
      tab_car[7]=B00000000;
    break;
    // 5
    case 53 :
      tab_car[0]=B01111100;
      tab_car[1]=B01000000;
      tab_car[2]=B01000000;
      tab_car[3]=B01111000;
      tab_car[4]=B00000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // 6
    case 54 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000000;
      tab_car[3]=B01111000;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // 7
    case 55 :
      tab_car[0]=B01111100;
      tab_car[1]=B01000100;
      tab_car[2]=B00001000;
      tab_car[3]=B00010000;
      tab_car[4]=B00100000;
      tab_car[5]=B01000000;
      tab_car[6]=B01000000;
      tab_car[7]=B00000000;
    break;
    // 8
    case 56 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B00111000;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // 9
    case 57 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B00111100;
      tab_car[4]=B00000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // :
    case 58 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000000;
      tab_car[2]=B00000000;
      tab_car[3]=B00000000;
      tab_car[4]=B00010000;
      tab_car[5]=B00000000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // <
    case 60 :
      tab_car[0]=B00000000;
      tab_car[1]=B00001000;
      tab_car[2]=B00010000;
      tab_car[3]=B00100000;
      tab_car[4]=B00010000;
      tab_car[5]=B00001000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // =
    case 61 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000000;
      tab_car[2]=B01111100;
      tab_car[3]=B00000000;
      tab_car[4]=B01111100;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // >
    case 62 :
      tab_car[0]=B00000000;
      tab_car[1]=B00100000;
      tab_car[2]=B00010000;
      tab_car[3]=B00001000;
      tab_car[4]=B00010000;
      tab_car[5]=B00100000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // ?
    case 63 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B00001000;
      tab_car[4]=B00010000;
      tab_car[5]=B00000000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // @
    case 64 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01011100;
      tab_car[3]=B01010100;
      tab_car[4]=B01011100;
      tab_car[5]=B01000000;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // A
    case 65 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01111100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // B
    case 66 :
      tab_car[0]=B01111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01111000;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B01111000;
      tab_car[7]=B00000000;
    break;
    // C
    case 67 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000000;
      tab_car[3]=B01000000;
      tab_car[4]=B01000000;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // D
    case 68 :
      tab_car[0]=B01111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01000100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B01111000;
      tab_car[7]=B00000000;
    break;
    // E
    case 69 :
      tab_car[0]=B01111100;
      tab_car[1]=B01000000;
      tab_car[2]=B01000000;
      tab_car[3]=B01110000;
      tab_car[4]=B01000000;
      tab_car[5]=B01000000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // F
    case 70 :
      tab_car[0]=B01111100;
      tab_car[1]=B01000000;
      tab_car[2]=B01000000;
      tab_car[3]=B01110000;
      tab_car[4]=B01000000;
      tab_car[5]=B01000000;
      tab_car[6]=B01000000;
      tab_car[7]=B00000000;
    break;
    // G
    case 71 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000000;
      tab_car[3]=B01011100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // H
    case 72 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01111100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // I
    case 73 :
      tab_car[0]=B01111100;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00010000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // J
    case 74 :
      tab_car[0]=B01111100;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00010000;
      tab_car[4]=B00010000;
      tab_car[5]=B01010000;
      tab_car[6]=B00100000;
      tab_car[7]=B00000000;
    break;
    // K
    case 75 :
      tab_car[0]=B01000100;
      tab_car[1]=B01001000;
      tab_car[2]=B01010000;
      tab_car[3]=B01100000;
      tab_car[4]=B01010000;
      tab_car[5]=B01001000;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // L
    case 76 :
      tab_car[0]=B01000000;
      tab_car[1]=B01000000;
      tab_car[2]=B01000000;
      tab_car[3]=B01000000;
      tab_car[4]=B01000000;
      tab_car[5]=B01000000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // M
    case 77 :
      tab_car[0]=B01000100;
      tab_car[1]=B01101100;
      tab_car[2]=B01010100;
      tab_car[3]=B01000100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // N
    case 78 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B01100100;
      tab_car[3]=B01010100;
      tab_car[4]=B01001100;
      tab_car[5]=B01000100;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // O
    case 79 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01000100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // P
    case 80 :
      tab_car[0]=B01111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01111000;
      tab_car[4]=B01000000;
      tab_car[5]=B01000000;
      tab_car[6]=B01000000;
      tab_car[7]=B00000000;
    break;
    // Q
    case 81 :
      tab_car[0]=B00010000;
      tab_car[1]=B00101000;
      tab_car[2]=B01000100;
      tab_car[3]=B01000100;
      tab_car[4]=B01010100;
      tab_car[5]=B00101000;
      tab_car[6]=B00010100;
      tab_car[7]=B00000000;
    break;
    // R
    case 82 :
      tab_car[0]=B01111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01111000;
      tab_car[4]=B01010000;
      tab_car[5]=B01001000;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // S
    case 83 :
      tab_car[0]=B00111000;
      tab_car[1]=B01000100;
      tab_car[2]=B01000000;
      tab_car[3]=B00111000;
      tab_car[4]=B00000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // T
    case 84 :
      tab_car[0]=B01111100;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00010000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // U
    case 85 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01000100;
      tab_car[4]=B01000100;
      tab_car[5]=B01000100;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // V
    case 86 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B00101000;
      tab_car[3]=B00101000;
      tab_car[4]=B00101000;
      tab_car[5]=B00010000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // W
    case 87 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B01000100;
      tab_car[3]=B01000100;
      tab_car[4]=B01010100;
      tab_car[5]=B01101100;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // X
    case 88 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B00101000;
      tab_car[3]=B00010000;
      tab_car[4]=B00101000;
      tab_car[5]=B01000100;
      tab_car[6]=B01000100;
      tab_car[7]=B00000000;
    break;
    // Y
    case 89 :
      tab_car[0]=B01000100;
      tab_car[1]=B01000100;
      tab_car[2]=B00101000;
      tab_car[3]=B00101000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // Z
    case 90 :
      tab_car[0]=B01111100;
      tab_car[1]=B00000100;
      tab_car[2]=B00001000;
      tab_car[3]=B00010000;
      tab_car[4]=B00100000;
      tab_car[5]=B01000000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // [
    case 91 :
      tab_car[0]=B00111000;
      tab_car[1]=B00100000;
      tab_car[2]=B00100000;
      tab_car[3]=B00100000;
      tab_car[4]=B00100000;
      tab_car[5]=B00100000;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // \
    case 92 :
      tab_car[0]=B00000000;
      tab_car[1]=B01000000;
      tab_car[2]=B00100000;
      tab_car[3]=B00010000;
      tab_car[4]=B00001000;
      tab_car[5]=B00000100;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // ]
    case 93 :
      tab_car[0]=B00111000;
      tab_car[1]=B00001000;
      tab_car[2]=B00001000;
      tab_car[3]=B00001000;
      tab_car[4]=B00001000;
      tab_car[5]=B00001000;
      tab_car[6]=B00111000;
      tab_car[7]=B00000000;
    break;
    // ^
    case 94 :
      tab_car[0]=B00010000;
      tab_car[1]=B00101000;
      tab_car[2]=B01000100;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    // _
    case 95 :
      tab_car[0]=B00000000;
      tab_car[1]=B00000000;
      tab_car[2]=B00000000;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B01111100;
      tab_car[7]=B00000000;
    break;
    // {
    case 123 :
      tab_car[0]=B00001000;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00100000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B00001000;
      tab_car[7]=B00000000;
    break;
    // |
    case 124 :
      tab_car[0]=B00010000;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00010000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B00010000;
      tab_car[7]=B00000000;
    break;
    // }
    case 125 :
      tab_car[0]=B00100000;
      tab_car[1]=B00010000;
      tab_car[2]=B00010000;
      tab_car[3]=B00001000;
      tab_car[4]=B00010000;
      tab_car[5]=B00010000;
      tab_car[6]=B00100000;
      tab_car[7]=B00000000;
    break;
    // ~ (°)
    case 126 :
      tab_car[0]=B00011100;
      tab_car[1]=B00010100;
      tab_car[2]=B00011100;
      tab_car[3]=B00000000;
      tab_car[4]=B00000000;
      tab_car[5]=B00000000;
      tab_car[6]=B00000000;
      tab_car[7]=B00000000;
    break;
    }
  }

void lire_ds3231()
  {
  unsigned char date_heure[7],index=0;

  Wire.beginTransmission(0x68); // adresse I2C du circuit DS3231 (104)
  Wire.write(0x00);             // adresse du premier registre à lire
  Wire.endTransmission();       // ne pas déplacer (instruction à mettre après le dernier "write") !
  Wire.requestFrom(0x68,7);
  while (Wire.available()) date_heure[index++]=Wire.read();
  // jour du mois
  tab_date[0]=(date_heure[4]>>4)+48;
  tab_date[1]=(date_heure[4]&0x0F)+48;
  tab_date[2]='/';
  // mois
  tab_date[3]=(date_heure[5]>>4)+48;
  tab_date[4]=(date_heure[5]&0x0F)+48;
  tab_date[5]='/';
  // année
  tab_date[6]='2';
  tab_date[7]='0';
  tab_date[8]=(date_heure[6]>>4)+48;
  tab_date[9]=(date_heure[6]&0x0F)+48;
  tab_date[10]=0;
  // heures
  tab_heure[0]=(date_heure[2]>>4)+48;
  tab_heure[1]=(date_heure[2]&0x0F)+48;
  tab_heure[2]=':';
  // minutes
  tab_heure[3]=(date_heure[1]>>4)+48;
  tab_heure[4]=(date_heure[1]&0x0F)+48;
  tab_heure[5]=':';
  // secondes
  tab_heure[6]=(date_heure[0]>>4)+48;
  tab_heure[7]=(date_heure[0]&0x0F)+48;
  tab_heure[8]=0;
  }

N'oubliez pas de modifier les paramètres en fonction de votre réseau !



Haut de page