[Programmation] matrice RGB
Répondre à la discussion
Affichage des résultats 1 à 4 sur 4

matrice RGB



  1. #1
    invitecf056cd3

    matrice RGB


    ------

    Bonjour
    j'ai entrain de faire un projet dans le quel je travaille avec des matrices LED RGB, j'ai eu beaucoup de mal a faire fonctionner ces matrice par que je maîtrisais pas trop le protocole SPI.
    maintenant j'arrive a faire allumer et éteindre soit un capteur de lumière ou avec un capteur de présence.
    cependant, étant donné que le capteur de présence est un capteur tout ou rien, donc je peux que allumer ou éteindre la matrice. et mon objectif est de l'allumer progressivement, c'est à dire ligne après ligne avec un certain temps. j'ai essayé de mettre de délais dans tous le sens mais ca marche pas.

    j'ai l'impression que j'ai un souci avec ces délais là même, par ce que de que j'enlève les délais, la matrice fonctionne (allumer/ éteindre)
    donc je sollicite votre aide pour me débloquer sur ce point.
    merci d avance

    -----

  2. #2
    PIXEL

    Re : matrice RGB

    hello ,

    le shéma du truc ?

  3. #3
    invitecf056cd3

    Re : matrice RGB

    voilà le programme: qui permet d'allumer la matrice en utilisant le capteur de présence, mon objectif est d'allumer ligne apres ligne, (mais pas en une seule fois le 8 lignes de la matrice)............;avez vous une idee
    merci

    Code HTML:
    #define CHIPSELECT 10//ss
    #define SPICLOCK  13//sck
    #define DATAOUT 11//MOSI / DI
    #define DATAIN 12//MISO / DO
    
    const int InfraredSensorPin = 4;//Connect the signal pin to the digital pin 4
    
    
    int b=0xFF;// couleur de leds : blanche
    
    const int analogPin = A0;   // the pin that the potentiometer is attached to
    const int ledCount = 8;    // the number of LEDs in the bar graph
    int datax[]=
    {
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b,
      b,b,b,b,b,b,b,b};
    
    
    int data[] = 
    {0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0
    };
    char spi_transfer(volatile char data)
    {
     SPDR = data;                    // Start the transmission
     while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
     {
     };
    }
    
    void setup()
    {
     byte clr;
     pinMode(DATAOUT,OUTPUT);
     pinMode(SPICLOCK,OUTPUT);
     pinMode(CHIPSELECT,OUTPUT);
     digitalWrite(CHIPSELECT,HIGH); //disable device
    
     SPCR = B01010001;             //SPI Registers ?????
     SPSR = SPSR & B11111110;      //make sure the speed is 125KHz
    
     /*
     SPCR bits:
      7: SPIEE - enables SPI interrupt when high
      6: SPE - enable SPI bus when high
      5: DORD - LSB first when high, MSB first when low
      4: MSTR - arduino is in master mode when high, slave when low
      3: CPOL - data clock idle when high if 1, idle when low if 0
      2: CPHA - data on falling edge of clock when high, rising edge when low
      1: SPR1 - set speed of SPI bus
      0: SPR0 - set speed of SPI bus (00 is fastest @ 4MHz, 11 is slowest @ 250KHz)
      */
     Serial.begin(9600);
      Serial.println("Start!");  
      pinMode(InfraredSensorPin,INPUT); 
     //SPCR = (1<<SPE)|(1<<MSTR); // ??? ajouté
     clr=SPSR;
     clr=SPDR;
     delay(10);
    }
    
    void loop()            
    {
      if(digitalRead(InfraredSensorPin) == LOW) 
        presence_objet();
      else  
      non_presence();   
    }
    void presence_objet()
    { 
     {
     // int ledLevel;
        //ledLevel=led();
      digitalWrite(CHIPSELECT,LOW); // enable the ChipSelect on the backpack
      delayMicroseconds(500); 
       for (int i=0;i<8;i++)
       for (int j=0;j<8;j++) 
       {
         spi_transfer(datax[i]);
         //delay(10);
          
    // There are only 8 colours available to the matrix with the 
    // backpack, so this will present 1 colour per column on the matrix
       }
      delay(10);
      //digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
      //delayMicroseconds(500);
       //delayMicroseconds(10);
        for (int i=0;i<8;i++) 
         for (int j=0;j<8;j++)
       {
         spi_transfer(data[i]);
       }
       
       digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
      delayMicroseconds(500);
     
    }
     }
     void non_presence()
     { 
      {
       digitalWrite(CHIPSELECT,LOW); // enable the ChipSelect on the backpack
      delayMicroseconds(500);
         for (int i=0;i<8;i++) 
         for (int j=0;j<8;j++)
       {
         spi_transfer(data[i]);
       }
       
       digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
      delayMicroseconds(500);}
       
    }

  4. #4
    invitecf056cd3

    Re : matrice RGB

    Citation Envoyé par PIXEL Voir le message
    hello ,

    le shéma du truc ?
    Bonjour PIXEL : voilà le programme (le début)
    le schema de la matrice RGB : https://www.sparkfun.com/products/760

  5. A voir en vidéo sur Futura

Discussions similaires

  1. Matlab: Comment exécuter matrice par matrice dans différents fichiers donnés?
    Par invite6aa93661 dans le forum Programmation et langages, Algorithmique
    Réponses: 19
    Dernier message: 21/05/2014, 15h05
  2. Réponses: 6
    Dernier message: 23/08/2013, 15h38
  3. Décomposition d'une matrice identité - Matrice ayant presque les mêmes propriétés
    Par inviteb31e526f dans le forum Mathématiques du supérieur
    Réponses: 6
    Dernier message: 14/06/2013, 11h13
  4. [Matrice] Determiner la matrice diagonale à partir de la matrice inverse
    Par invite9bb30a60 dans le forum Mathématiques du supérieur
    Réponses: 1
    Dernier message: 08/06/2012, 16h48
  5. Réponses: 1
    Dernier message: 16/09/2009, 19h37
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...