Pages: [1]   Go Down
Author Topic: Help with code for RGB matrix 10x10  (Read 590 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, i'm new in arduino and need help. I follow this project http://solderlab.de/index.php/led-projects/rgb-matrix-12x8
 and create rgb led matrix 10x10. I try for test posted code 12x8 and display color are great but of course not show any animations correct. Please anyone can me help to create custom code (sketch) for my 10x10 rgb led matrix.

Code:
//Hauptprogram auf dem µ-Controler
//Von hier aus werden die einzelnen Unterprogramme zufällig gestartet
//FĂĽr Unterprogramme mit variabler Abspielgeschwindigkeit sowie Abspieldauer werden diese gleich ausgewĂĽrfelt und als Parameter ĂĽbergeben
//Das unterprogramm "Movies" (play_sequence) wird mit mehrmals wiederholt

//Definition der Ausgangspins am µ-Controller
#define latchPin    10 // Enable SR after data refresh
#define PIN_SCK     13 // SPI clock
#define PIN_MISO    12 // SPI data input
#define PIN_MOSI    11 // SPI data output

//Vordefinitionen fĂĽr ADC-Raten-Einstellung
#define FASTADC 1
#ifndef cbi
  #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
  #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif


//Startframes fĂĽr die "Laola"-Prozedur(en)
byte  counter_1[6] = {0,1,2,3,4,5};
byte richtung_1[6] = {1,1,1,1,1,1};
byte  counter_2[6] = {0,2,4,4,2,0};
byte richtung_2[6] = {1,1,1,1,1,1};
byte  counter_3[6] = {0,6,0,6,0,6};
byte richtung_3[6] = {1,0,1,0,1,0};
byte  counter_4[6];
byte richtung_4[6];

//Puffer fĂĽr die LEDs
byte buffer_r[] = {0,0,0,0,0,0,0,0,0,0,0,0}; //Puffer fĂĽr die roten  LEDs (12 byte entspechen 12 Spalten)
byte buffer_g[] = {0,0,0,0,0,0,0,0,0,0,0,0}; //Puffer fĂĽr die grĂĽnen LEDs (12 byte entspechen 12 Spalten)
byte buffer_b[] = {0,0,0,0,0,0,0,0,0,0,0,0}; //Puffer fĂĽr die blauen LEDs (12 byte entspechen 12 Spalten)

//Setup-Prozedur bereitet den µ-Controller auf den Ablauf vor - Die Ausgangspins werden dabei als digitale AUSGÄNGE definiert
void setup()   
{               
  //Pins auf Ein- oder Ausgang stellen und einen Startwert zuweisen
  pinMode(latchPin, OUTPUT);
  pinMode(PIN_SCK,  OUTPUT);       
  pinMode(PIN_MOSI, OUTPUT);
  pinMode(PIN_MISO,  INPUT);
  digitalWrite(latchPin,  LOW);
  digitalWrite(PIN_SCK,   LOW);
  digitalWrite(PIN_MOSI,  LOW);
  digitalWrite(PIN_MISO, HIGH);
 
  //SPI Comunication voerbereiten
  SPCR = B01110000;
 
  //SPI Control Register (SPCR)
 
  // | 7    | 6    | 5    | 4    | 3    | 2    | 1    | 0    |
  // | SPIE | SPE  | DORD | MSTR | CPOL | CPHA | SPR1 | SPR0 |

  // SPIE - Enables the SPI interrupt when 1
  // SPE  - Enables the SPI when 1
  // DORD - Sends data least Significant Bit First when 1, most Significant Bit first when 0
  // MSTR - Sets the Arduino in master mode when 1, slave mode when 0
  // CPOL - Sets the data clock to be idle when high if set to 1, idle when low if set to 0
  // CPHA - Samples data on the falling edge of the data clock when 1, rising edge when 0
  //SPR1 and SPR0 - Sets the SPI speed, 00 is fastest (4MHz) 11 is slowest (250KHz)
 
  SPSR = B00000000; //SPI Status Register
 
  //ADC-Taktung erhöhen 
  #if FASTADC
    sbi(ADCSRA,ADPS2);
    cbi(ADCSRA,ADPS1);
    cbi(ADCSRA,ADPS0);
  #endif
 
  Serial.begin(9600);
 
}

//Hauptschleife die immer wieder wiederholt wird 
void loop()                     

  randomSeed(millis()+random(255)); //Benutzt die aktuelle Systemzeit in ms als Ausgangsparameter fĂĽr die nächste "Zufallszahlen"-Berechnung
  switch (random(12))
  //switch (16)
  {
    case  0: Moving_RGB_Lines                            (random(5,20),random( 40, 150));   break;
    case  1: Jumping_RGB_Balls                           (random(5,20),random( 50, 200));   break;
    case  2: Moving_Rainbow                              (random(5,20),random( 50, 200));   break;   
  //case  3: Random_Shift                                (random(5,20),random( 70, 250));   break;   
  //case  4: Laola(counter_1, richtung_1,                 random(5,20),random( 70, 150));   break;     
  //case  5: Laola(counter_2, richtung_2,                 random(5,20),random( 70, 150));   break;
  //case  6: Laola(counter_3, richtung_3,                 random(5,20),random( 70, 150));   break;
    case  3: for (int i=0; i<6; i++)
             {
               counter_4 [i]=random(1,7);
               richtung_4[i]=random(2  );
             }
             Laola(counter_4, richtung_4,                 random(5,20),random( 70, 150));   break;
    case  4: Display_String                              (             random( 70, 150));   break;
    case  5: equalizer                                   (random(5,20)                 );   break;
    case  6: equalizer_2                                 (random(5,20)                 );   break;
    case  7: for (byte i=0; i<random(10); i++) {play_sequence(Sequence_01);}                break;
    case  8: for (byte i=0; i<random(10); i++) {play_sequence(Sequence_02);}                break;
    case  9: Rainbow_PWM                                 (random(5,30),random( 40, 100));   break;
  //case 14: Random_PWM                                  (random(5,20),random( 70, 250));   break;
  //case 15: Billiard_PWM                                (random(5,20),random( 70, 100));   break;
    case 10: Plasma_PWM                                  (random(9,30),random( 50, 100));   break;
    case 11: Blobb_PWM                       (random(1,5),random(9,30),random(      50));   break; 
  //case 18: Test_Run();                                                                    break;
  }
}

I'm not programmer and need help with modification some other code.
I try to change this and delete last two zero for all colour and display showing better. But I cant found what need change for add more 2 colomun to be 10 colomun.

byte buffer_r[] = {0,0,0,0,0,0,0,0,0,0,0,0};
byte buffer_g[] = {0,0,0,0,0,0,0,0,0,0,0,0};
byte buffer_b[] = {0,0,0,0,0,0,0,0,0,0,0,0};


Please correct me if this is not possible to change, and I need advice on which program can do make custom LED matrix.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If anyone knows any other code for 10 x 10 please post.
Logged

Pages: [1]   Go Up
Jump to: