Découvrez notre Chaîne YouTube "Ingénierie et Projets"
Découvrez notre Chaîne Secondaire "Information Neuronale et l'Ingénierie du Cerveau"

Projet électronique Gestion d'une matrice des LED avec Arduino - MAX7219CNG

Projet électronique Gestion d'une matrice des LED avec Arduino - Principe

Objectifs et analyse de fonctionnement

Le projet consiste la gestion d’une matrice des LED 8X8 à base d’Arduino en utilisant le circuit MAX7219CNG. Le projet électronique utilise une libraire pour la gestion du circuit MAX7219CNG avec une liaison SPI. Ce mini projet mis en évidence l’utilisation de la libraire avec d’autres fonctions secondaires (décalage, conversion, …).

Fonctionnement de la matrice des LEDs 8×8

Projet électronique Gestion d'une matrice des LED avec Arduino - matrice led

La matrice des LED est constituée de 8 lignes et 8 colonnes. On peut assimiler la matrice à un tableau 1D de 8 éléments, chaque élément du tableau est codé sur 8 bits Ex B00001111 ou 0x0F, dans la figure ci-dessous illustre le passage d’une matrice 8×8 à un tableau sur 8 éléments de type Bye ou Unsigned char. On verra dans la suite la fonction qui permet d’afficher le code dans la matrice 8×8.

Le module utilisé est basé sur MAX7219 avec une liaison série pour les données. Le bus SPI est constitué de trois fils :

  • CS : Chip Select pour l’activation du modèle
  • CLK : l’horloge synchrone pour les données. L’horloge définie la vitesse de transmission des données série
  • DIN : La donnée série sur 8 bits

Plus des détails sur la transmission série : SPI 

Projet électronique Gestion d'une matrice des LED avec Arduino - Matrice fonctionnement

Lien vers une Application gratuite de gestion d’une matrice 8×8 des LED

Commentaires sur le programme

void int2BitArray(unsigned char dataIn,unsigned char taille, byte *dataArray)

La fonction int2BitArray permet de convertir une variable char en un tableau sur N bits (N=8 bits)

Ex1 : pour dataIn=10, taille=8 alors la variable de sortie dataArray[8]={0,0,0,0,1,0,1,0] ( équivalant à B00001010)
Ex2 : dataIn=127, taille=8 alors la variable de sortie dataArray[8]={0,1,1,1,1,1,1,1] ( équivalant à B011111111)

void DataShiftArray(unsigned char NumShift,unsigned char taille, byte *DataIn, byte *DataOutShift)

La fonction DataShiftArray permet de décaler à droit un tableau de longueur « taille » de bits (tableau binaire) DataIn, le résultat est stocké puis retourné dans le tableau DataOutShift. Au début le tableau DataOutShift est supposé initialisé à 0.

Ex : NumShift=3, taille = 8, DataIn[8]={1,1,1,1,0,0,0,0} alors DataOutShift[8]={0,0,0,1,1,1,1,0}.

L’objectif de la fonction est de décaler un objet dans la matrice 8×8 des LED.

Les fonctions disponibles dans la libraire LedControl.h (MAX7219/MAX7221)

class LedControl {
    private
        /* The array for shifting the data to the devices */
        byte spidata[16];
        /* Send out a single command to the device */
        void spiTransfer(int addr, byte opcode, byte data);

        /* We keep track of the led-status for all 8 devices in this array */
        byte status[64];
        /* Data is shifted out of this pin*/
        int SPI_MOSI;
        /* The clock is signaled on this pin */
        int SPI_CLK;
        /* This one is driven LOW for chip selectzion */
        int SPI_CS;
        /* The maximum number of devices we use */
        int maxDevices;

    public:
        /*
         * Create a new controler
         * Params :
         * dataPin                pin on the Arduino where data gets shifted out
         * clockPin                pin for the clock
         * csPin                pin for selecting the device
         * numDevices        maximum number of devices that can be controled
         */
        LedControl(int dataPin, int clkPin, int csPin, int numDevices=1);

        /*
         * Gets the number of devices attached to this LedControl.
         * Returns :
         * int        the number of devices on this LedControl
         */
        int getDeviceCount();

        /*
         * Set the shutdown (power saving) mode for the device
         * Params :
         * addr        The address of the display to control
         * status        If true the device goes into power-down mode. Set to false
         *                for normal operation.
         */
        void shutdown(int addr, bool status);

        /*
         * Set the number of digits (or rows) to be displayed.
         * See datasheet for sideeffects of the scanlimit on the brightness
         * of the display.
         * Params :
         * addr        address of the display to control
         * limit        number of digits to be displayed (1..8)
         */
        void setScanLimit(int addr, int limit);

        /*
         * Set the brightness of the display.
         * Params:
         * addr                the address of the display to control
         * intensity        the brightness of the display. (0..15)
         */
        void setIntensity(int addr, int intensity);

        /*
         * Switch all Leds on the display off.
         * Params:
         * addr        address of the display to control
         */
        void clearDisplay(int addr);

        /*
         * Set the status of a single Led.
         * Params :
         * addr        address of the display
         * row        the row of the Led (0..7)
         * col        the column of the Led (0..7)
         * state        If true the led is switched on,
         *                if false it is switched off
         */
        void setLed(int addr, int row, int col, boolean state);

        /*
         * Set all 8 Led's in a row to a new state
         * Params:
         * addr        address of the display
         * row        row which is to be set (0..7)
         * value        each bit set to 1 will light up the
         *                corresponding Led.
         */
        void setRow(int addr, int row, byte value);

        /*
         * Set all 8 Led's in a column to a new state
         * Params:
         * addr        address of the display
         * col        column which is to be set (0..7)
         * value        each bit set to 1 will light up the
         *                corresponding Led.
         */
        void setColumn(int addr, int col, byte value);

        /*
         * Display a hexadecimal digit on a 7-Segment Display
         * Params:
         * addr        address of the display
         * digit        the position of the digit on the display (0..7)
         * value        the value to be displayed. (0x00..0x0F)
         * dp        sets the decimal point.
         */
        void setDigit(int addr, int digit, byte value, boolean dp);

        /*
         * Display a character on a 7-Segment display.
         * There are only a few characters that make sense here :
         *        '0','1','2','3','4','5','6','7','8','9','0',
         *  'A','b','c','d','E','F','H','L','P',
         *  '.','-','_',' '
         * Params:
         * addr        address of the display
         * digit        the position of the character on the display (0..7)
         * value        the character to be displayed.
         * dp        sets the decimal point.
         */
        void setChar(int addr, int digit, char value, boolean dp);
};

Exemple de programme d’utilisation de la libraire


//Libraire à importer !
#include "LedControl.h"

/*
 Configuration des pins (MAX72XX)
 LedControl lc=LedControl(12,11,10,1);
 Pin 12  connecté au DataIn
 Pin 11  connecté au CLK
 Pin 10  connecté au LOAD
*/

LedControl lc=LedControl(12,10,11,1);

/* Temporisation de mise en service de l'afficheur */
unsigned long delaytime=100;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
  */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}

void writeArduinoOnMatrix() {

  /* Tableaux de 8 Byte, chaque octet est constitué de 8 bits (8x8=64) */
  byte t[8]={B00000000,B11111111,B11111111,B00011000,B00011000,B00011000,B00011000,B00011000};
  byte Data[8]={0,0,0,0,0,0,0,0};
  byte DataShif[8]={0,0,0,0,0,0,0,0};
  byte XData[8]={B10111101,B11000011,B10011001,B10011001,B01000010,B01111110,B10011001,B10011001};
  byte EM[8]={B11110001,B11000011,B10100101,B10011001,B11111001,B10000001,B10000001,B11110001};

  /* Affichage du caractère T colonne par colonne (8écritures) */
  for(int i=0;i<8;i++)
  {
    // Afficher la ligne t[i] à la position de la colonne i
    lc.setColumn(0,i,t[i]);
    delay(delaytime);
  }
  lc.clearDisplay(0);

  delay(1000);

  /* Affichage du caractère T ligne par ligne (Rotation 90° par rapport
  à la fonction setColumn ((8 écritures)*/
  for(int i=0;i<8;i++)
  {
    // Afficher la colonne t[i] à la position de la ligne i
    lc.setRow(0,i,t[i]);
    delay(delaytime);
  }
  lc.clearDisplay(0);
  delay(1000);

  /* Ecriture dans l'afficheur pixel par pixel (8x8 écritures) */
  for(int k=0;k<8;k++)
  {
    //Décalage à droite de valeur=k [0..7]
    DataShiftArray(k,8, EM,DataShif )  ;
    for(int i=0;i<8;i++)
    {
      // Conversion du Byte DataShif[i] en binaire sur 8 bits
      int2BitArray( DataShif[i],8 ,Data );
      for(int j=0;j<8;j++)
      {
        // Affichage le Bit Data[j] à la position (i,j) de la matrice (8x8)
        lc.setLed(0,i,j,Data[j]);
        //delay(1);
      }
    }
    delay(1000);
    lc.clearDisplay(0);
  }

}

void int2BitArray(unsigned char dataIn,unsigned char taille, byte *dataArray)
{
  int i=0;

  for(i=0;i<taille;i++)
    dataArray[taille-i-1]= (dataIn>>i)&0x01;
}

void DataShiftArray(unsigned char NumShift,unsigned char taille,  byte *DataIn, byte *DataOutShift)
{
  int i=0;

  for(i=0;i<taille;i++)
    DataOutShift[i]= (DataIn[i]>>NumShift);
}

void loop() {
  writeArduinoOnMatrix();
}

Fichiers projets + Libraire en C du projet électronique (.rar)  

Photos du projet électronique

Projet-électronique-Gestion-dune-matrice-des-LED-avec-Arduino-photos-projet-7 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 7 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 5 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 6 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 4 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 3 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 2 Projet électronique Gestion d'une matrice des LED avec Arduino - photos projet 1

Rappel des cours:

[stextbox id= »info » ]Cours Arduino
Composants électroniques[/stextbox]

Un petit commentaire de vous, un Grand encouragement pour nous :)

– Bon Courage –

Click to rate this post!
[Total: 3 Average: 5]

13 commentaires

attari · 2022-06-03 à 7:38

Vous avez un excellent site, vos explications sont satisfaisantes , je vous remercie beaucoup et je vous souhaite bon continuation.

BURAISU SAMA · 2020-10-29 à 11:57

svp j’aimerais construire une matrice a led 64*64 doc 4096 leds et j’ai chercher sur le net des méthodes pour y arriver mais hélas. Je ne trouve que des montages déja élaborés et fonctionnel comme ceux du P10 Matrix LED. j’aimerais donc avoir un peu d’aide si quelqu’un s’y connait

    admin · 2020-10-30 à 12:28

    Bonjour, tu peux utiliser 64 matrices de 8×8 que tu câbles en parallèles. Tu peux programmer d’une façon individuelle les matrices 8×8 en activant le circuits via le pin CE (pour désactiver le circuit il suffit de mettre le pin à 0). Du coup il te faut 64 pins de commandes!!! C bcp ou 16 matrices de 16×16, ou 4 pour 32×32. Pour générer les commandes et réduire le nombre de pins, c mieux d’utiliser un demux 1/64 ou 1/16…

Gwendoline Duval · 2020-05-13 à 8:18

Bonjour,
Serait-il possible de savoir comment afficher un mot avec une matrice led 16×32?
Merci d’avance

    admin · 2020-08-16 à 7:22

    Bonjour, Vous pouvez utiliser plusieurs afficheurs en cascade. Il suffit de préciser l’adresse de l’afficheur pour lequel tu veux envoyé la donnée. Le pin « CE » peut être utilisé pour sélectionné l’afficheur en question.

jean-louis GUIFFAULT · 2019-10-03 à 9:37

bonjour,
les sujets sont traités de façon claire les pages sont lisibles,claires (pas encombrées de pubs inutiles).
Très bon travail.
Je voulais vous posez la question suivante :
J’utilise Arduino MEGA2560 R3, cela a t-il une incidence sur les branchements et la gestion d’une matrice led Max7219.
Merci.

    admin · 2019-10-10 à 5:17

    Bonjour. Merci pour le commentaire. Non je ne pense pas, il suffit juste de vérifier le câblage. Bon courage.

olivier · 2019-05-08 à 12:47

pas super clair

Jack · 2015-12-17 à 1:44

Merci pour les articles

Jack · 2015-12-17 à 1:44

Merci pour les projets

mapub · 2015-12-16 à 7:06

quelqu’un pour bossé ensemble sur des panneaux en led ??

kira · 2015-12-16 à 3:44

Merci pour le partage 🙂 🙂

Laisser un commentaire

Avatar placeholder

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Anti-Robot *

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Privacy Policy

What information do we collect?

We collect information from you when you register on our site or place an order. When ordering or registering on our site, as appropriate, you may be asked to enter your: name, e-mail address or mailing address.

What do we use your information for?

Any of the information we collect from you may be used in one of the following ways: To personalize your experience (your information helps us to better respond to your individual needs) To improve our website (we continually strive to improve our website offerings based on the information and feedback we receive from you) To improve customer service (your information helps us to more effectively respond to your customer service requests and support needs) To process transactions Your information, whether public or private, will not be sold, exchanged, transferred, or given to any other company for any reason whatsoever, without your consent, other than for the express purpose of delivering the purchased product or service requested. To administer a contest, promotion, survey or other site feature To send periodic emails The email address you provide for order processing, will only be used to send you information and updates pertaining to your order.

How do we protect your information?

We implement a variety of security measures to maintain the safety of your personal information when you place an order or enter, submit, or access your personal information. We offer the use of a secure server. All supplied sensitive/credit information is transmitted via Secure Socket Layer (SSL) technology and then encrypted into our Payment gateway providers database only to be accessible by those authorized with special access rights to such systems, and are required to?keep the information confidential. After a transaction, your private information (credit cards, social security numbers, financials, etc.) will not be kept on file for more than 60 days.

Do we use cookies?

Yes (Cookies are small files that a site or its service provider transfers to your computers hard drive through your Web browser (if you allow) that enables the sites or service providers systems to recognize your browser and capture and remember certain information We use cookies to help us remember and process the items in your shopping cart, understand and save your preferences for future visits, keep track of advertisements and compile aggregate data about site traffic and site interaction so that we can offer better site experiences and tools in the future. We may contract with third-party service providers to assist us in better understanding our site visitors. These service providers are not permitted to use the information collected on our behalf except to help us conduct and improve our business. If you prefer, you can choose to have your computer warn you each time a cookie is being sent, or you can choose to turn off all cookies via your browser settings. Like most websites, if you turn your cookies off, some of our services may not function properly. However, you can still place orders by contacting customer service. Google Analytics We use Google Analytics on our sites for anonymous reporting of site usage and for advertising on the site. If you would like to opt-out of Google Analytics monitoring your behaviour on our sites please use this link (https://tools.google.com/dlpage/gaoptout/)

Do we disclose any information to outside parties?

We do not sell, trade, or otherwise transfer to outside parties your personally identifiable information. This does not include trusted third parties who assist us in operating our website, conducting our business, or servicing you, so long as those parties agree to keep this information confidential. We may also release your information when we believe release is appropriate to comply with the law, enforce our site policies, or protect ours or others rights, property, or safety. However, non-personally identifiable visitor information may be provided to other parties for marketing, advertising, or other uses.

Registration

The minimum information we need to register you is your name, email address and a password. We will ask you more questions for different services, including sales promotions. Unless we say otherwise, you have to answer all the registration questions. We may also ask some other, voluntary questions during registration for certain services (for example, professional networks) so we can gain a clearer understanding of who you are. This also allows us to personalise services for you. To assist us in our marketing, in addition to the data that you provide to us if you register, we may also obtain data from trusted third parties to help us understand what you might be interested in. This ‘profiling’ information is produced from a variety of sources, including publicly available data (such as the electoral roll) or from sources such as surveys and polls where you have given your permission for your data to be shared. You can choose not to have such data shared with the Guardian from these sources by logging into your account and changing the settings in the privacy section. After you have registered, and with your permission, we may send you emails we think may interest you. Newsletters may be personalised based on what you have been reading on theguardian.com. At any time you can decide not to receive these emails and will be able to ‘unsubscribe’. Logging in using social networking credentials If you log-in to our sites using a Facebook log-in, you are granting permission to Facebook to share your user details with us. This will include your name, email address, date of birth and location which will then be used to form a Guardian identity. You can also use your picture from Facebook as part of your profile. This will also allow us and Facebook to share your, networks, user ID and any other information you choose to share according to your Facebook account settings. If you remove the Guardian app from your Facebook settings, we will no longer have access to this information. If you log-in to our sites using a Google log-in, you grant permission to Google to share your user details with us. This will include your name, email address, date of birth, sex and location which we will then use to form a Guardian identity. You may use your picture from Google as part of your profile. This also allows us to share your networks, user ID and any other information you choose to share according to your Google account settings. If you remove the Guardian from your Google settings, we will no longer have access to this information. If you log-in to our sites using a twitter log-in, we receive your avatar (the small picture that appears next to your tweets) and twitter username.

Children’s Online Privacy Protection Act Compliance

We are in compliance with the requirements of COPPA (Childrens Online Privacy Protection Act), we do not collect any information from anyone under 13 years of age. Our website, products and services are all directed to people who are at least 13 years old or older.

Updating your personal information

We offer a ‘My details’ page (also known as Dashboard), where you can update your personal information at any time, and change your marketing preferences. You can get to this page from most pages on the site – simply click on the ‘My details’ link at the top of the screen when you are signed in.

Online Privacy Policy Only

This online privacy policy applies only to information collected through our website and not to information collected offline.

Your Consent

By using our site, you consent to our privacy policy.

Changes to our Privacy Policy

If we decide to change our privacy policy, we will post those changes on this page.
Save settings
Cookies settings

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

FPGA | Arduino | Matlab | Cours will use the information you provide on this form to be in touch with you and to provide updates and marketing.