I bought the square led pixels from adafruit, this led's are all adressable and they are very simple to control.
We use this leds in a big 333mts cube, so to make the functions easier we make a virtual matrix.
What we try to do is to control the functions that we create with Ableton MIDI signals.
I'm using the hairless midi-serial program to do the midi-serial job. This works well.
The problem is that when I include the matrix thing in the midi reactive code the hole thing stops working.
But that's not all, the worst thing is that when I shrink the matrix the problem get's solved, but that's not an option because we need the whole matrix to be working.
This is the code:
#include "SPI.h"
#include "Adafruit_WS2801.h"
#include <stdio.h>
#include "MIDI.h"int dataPin = 2; // Yellow wire on Adafruit Pixels
int clockPin = 3; // Green wire on Adafruit Pixels
//int cubo[5][5][5]= {0};
int cubo[4][4][4] = {};Adafruit_WS2801 strip = Adafruit_WS2801(325, dataPin, clockPin);
//const int ledPin = 13;void setup() {
/*
int i, j, k;for (i=0; i<3; i++)
for (j=0; j<3; j++)
for (k=0; k<3; k++)
cubo*[j][k] =0;*
_ //printf("%i %i %i: %i\n", i, j, k, cubo*[j][k]);*__ */_
* llenarCubo();*
* MIDI.begin(MIDI_CHANNEL_OMNI);
_ Serial.begin(9600);_
_ MIDI.setHandleNoteOn(HandleNoteOn); // Put only the name of the function*_
* MIDI.setHandleNoteOff(HandleNoteOff);*
* strip.begin();*
* // Update LED contents, to start they are all 'off'*
* strip.show();*
* //pinMode(ledPin, OUTPUT);*}
void loop() {
* midi.poll();*
* //MIDI.read();*
* //void HandleNoteOn(byte channel, byte pitch, byte velocity);*
* //void HandleNoteOff(byte channel, byte pitch, byte velocity);*
* }** void HandleNoteOff(byte channel, byte pitch, byte velocity) { *
* if (velocity == 64){*
* for (int i=0; i < strip.numPixels(); i++) {*
* strip.setPixelColor(i, 0,0,0);*
* }*
* strip.show();*
* }** }*
* void HandleNoteOn(byte channel, byte pitch, byte velocity) {*
* if (pitch == 64) {*
* //fAbajoArriba();*
* for (int i=0; i < strip.numPixels(); i++) {*
* strip.setPixelColor(i, 255,0,0);*
* }*
* strip.show();*
* }** if (pitch == 60) {*
* //fArribaAbajo();*
* for (int i=0; i < strip.numPixels(); i++) {*
* strip.setPixelColor(i, 0,255,0);*
* }*
* strip.show();*
* }** if (pitch == 62) {*
* //fArribaAbajo2();*
* for (int i=0; i < strip.numPixels(); i++) {*
* strip.setPixelColor(i, 255,0,0);*
* }*
* strip.show();*
* }** // Try to keep your callbacks short (no delays ect) as the contrary would slow down the loop()*
* // and have a bad impact on real-time performance.*//fArribaAbajo2();
}
/**************************************** OTRAS *****************************************/
//
//void fAbajoArriba(){
// int a = random(0,13);
// int f = random(0,5);
// int ff = random(0,5);
// int g = random(0,256);
// for(int altura=0; altura<=a; altura++){
*// strip.setPixelColor(cubos[altura][f][ff], Color(255,g,0)); *
// strip.show();
// strip.setPixelColor(cubos[altura][f][ff], negro());
*// } *
//}
//
//void fArribaAbajo(){
*// *
// int a = random(0,13);
// int f = random(0,5);
// int ff = random(0,5);
// int g = random(0,256);
*// *
// for(int altura=a; altura>=0; altura--){
*// strip.setPixelColor(cubos[altura][f][ff], Color(255,g,0)); *
// strip.show();
// strip.setPixelColor(cubos[altura][f][ff], negro());
*// *
*// } *
//}
//
//void fArribaAbajo2(){
*// *
// int a = random(0,13);
// int f = random(0,5);
// int ff = random(0,5);
// int g = random(0,256);
*// *
// for(int altura=12; altura>=a; altura--){
*// strip.setPixelColor(cubos[altura][f][ff], Color(g,g,0)); *
// strip.show();
// strip.setPixelColor(cubos[altura][f][ff], negro());
*// *
*// } *
//}
//
//
//void fIzquierdaDerecha(){
*// *
// int a = random(0,13);
// int f = random(0,5);
// int ff = random(0,5);
// int g = random(0,256);
*// *
// for(int filas=f; filas>=0; filas--){
*// strip.setPixelColor(cubos[a][filas][ff], Color(255,g,0)); *
// strip.show();
// strip.setPixelColor(cubos[a][filas][ff], negro());
*// *
*// } *
//}
//
//void fDerechaIzquierda(){
*// *
// int a = random(0,13);
// int f = random(0,5);
// int ff = random(0,5);
// int g = random(0,256);
*// *
// for(int filas=0; filas<=f; filas++){
*// strip.setPixelColor(cubos[a][filas][ff], Color(255,g,0)); *
// strip.show();
// strip.setPixelColor(cubos[a][filas][ff], negro());
*// *
*// } *
//}
/************************ AUXILIARES ****************************/
//
//void tintinear(int a,int b,int c){
// for(int j=0; j<3; j=j++){
// fadeIn(a,b,c);
// fadeOut(a,b,c);
// strip.setPixelColor(cubos[a]
```c
**, negro());
// }
//}
//
//void fadeIn(int a,int b,int c){
// for(int i=0; i<200; i=i+30){
// strip.setPixelColor(cubos[a][b][c], blanco(i));
// strip.show();
// }
//}
//
//void fadeOut(int a,int b,int c){
// for(int i=200; i>=0; i=i-30){
// strip.setPixelColor(cubos[a][b][c], blanco(i));
// strip.show();
// }
//}
//
//void apagarcubos(){
// cubosBlanco(0);
//}
//
//void cubosBlanco(int a){
// for (int i=0; i < strip.numPixels(); i++) {
// strip.setPixelColor(i, blanco(a));
// }
// strip.show();
//}
//
boolean esPar(int numero){
return numero%2==0;
}
//
//uint32_t blanco(int intensidad){
// return Color(intensidad,intensidad,intensidad);
//}
//
//uint32_t negro(){
// return Color(0,0,0);
//}
//
/*
- Crea un cubos de 13x5x5 (leds)
- y relaciona a cada posicion, el led
- de la tira que le corresponde.
*/
void llenarCubo(){
int c = 0; // c es el numero de led
for(int k=0; k<4; k++){ //k es profundidad
for(int j=0; j<4; j++){
for(int i=0; i<4; i++){
cubo[k][j][i] = 0;
c++;
}
}
}
}
//
[/quote]
Here is the problem:
this way work's well ---------int cubo[4][4][4] = {};
this way doesn't work ----------------int cubo[5][5][5]= {};
It appears to be that the program can't support a more than 444 matrix. But we work with a 1355 matrix when creating the functions and
it was working fine. Please help we try with all as you can see in the code.
Thanks**
```