4x4x4 RGB LED Cube und Musik

Hallo alle zusammen,

bin ganz neu hier im Forum und habe vor kurzem erst mit Arduino angefangen und vorher auch noch keine Erfahrung mit µC gehabt.

Vor gut 3 Monaten bin Ich auf Youtube auf den 8x8x8 RGB LED Cube von Kevin Darrah gestoßen, den Ich auch dann nachgebaut habe. Läuft einwandfrei das Teil und macht auch jede Menge Spaß.

Nun habe Ich das ganze auf einen 4x4x4 RGB LED Cube verkleinert, den Code angepasst was auch alles super funktioniert. Der Cube soll ein Geschenk für meinen Schwiegervater sein, weshalb Ich Ihm eine LCD Anzeige (16.2) und ein paar Schalter spendiert habe, damit Er die Animationen auswählen und dort Parameter ändern kann ( zb. 4 verschiedene Farben bei Regen- Animation, Geschwindigkeit Wurm- Animation usw). Was Ich aber irgendwie nicht auf die Reihe bekomme, ist das der Cube auch auf Musik reagiert. Habe es gestern mit analogRead versucht aber irgendwie stehe Ich da wie eine Kuh vorm Berg.

Gesteuert wird der Cube über einen UNO , weil mit dem Mega spinnt der total was Ich auch noch nicht so ganz verstehe...SPI ist doch SPI oder??

Hoffe Ihr könnt mir da ein wenig helfen ???


Könntest du vielleicht mal den Code posten? Danke :slight_smile:
Außerdem benutzt du ein Mikrofon für die Musiksteuerung ? (Wahrscheinlich ja )

Sonst wenn du ein Mikrofon auslesen willst einfach folgenden Code nehmen

int analogPin = 1;
                  
int val = 0;      
int digital = 0; // 8-Bit Auflösung

void setup()
{
}

void loop()
{
  val = analogRead(analogPin); // read the input pin
  digital = map(val, 0, 1023, 0, 255); // Muss nicht sein, kann aber !
}

SPI ist schon SPI aber bei UNO und MEGA sind das nicht die gleichen Pins. Es sind immer die 6 ICSP-Pins aber nicht immer die Pins 11 bis 13. Näheres unter SPI - Arduino Reference .

Wie liest Du die Musik ein?
Grüeß Uwe

Wie füge Ich hier denn den Code ein?? Habe das schon über Sketch für Forum kopieren und dann über Insert Code versucht den einzufügen :~ ``

Also die Musik sollte schon später über ein Mikro eingelesen werden. Jetzt gerade hängt der AnalogPin an einer Box. Glaube werde da aber um eine kleine Verstärkerschaltung mit nem LM386N nicht herum kommen ?? Versuche gerade die Delayzeit von der Rain-Animation über die SensorValue zu steuern, aber das Signal ist glaub Ich zu schwach.

Das die Pins für die SPI beim Mega anders belegt sind habe Ich schon gesehen, aber irgendwie ist der zu schnell, kann das sein??

Also um code einzufügen einfach den Code mit command copy kopieren und dann bei der Nachricht auf insert code klicken (#) und dann zwischen diese beiden Klammern [] einfügen [] (command paste) hier einfügen

Wenn du auf mehr als die Lautstärke reagieren willst, brauchst die eine Fast Fourier oder Fast Hartley Transformation:
http://wiki.openmusiclabs.com/wiki/ArduinoFFT
http://wiki.openmusiclabs.com/wiki/ArduinoFHT

Damit zerlegst du das Signal in sein Frequenzspektrum

Beachte, dabei auch, dass du das Signal mit einem Spannungsteiler anheben musst, da das Wechselspannung ist:

http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/

Wichtig sind dabei die 10µF und zwei mal 100k

Und ja, du brauchst einen OpAmp

OK , dann versuche Ich es nochmal mit dem Code

#include <LiquidCrystal.h>
#include <SPI.h>

#define latch_pin 2// can use any pin you want to latch the shift registers
#define blank_pin 4// same, can use any pin you want for this, just make sure you pull up via a 1k to 5V
#define data_pin 11// used by SPI, must be pin 11
#define clock_pin 13// used by SPI, must be 13
#define buttonPin  7 // Kippschalter 1
#define buttonPin1 8 // Kippschater 2
#define buttonPin2 10 //Kippschalter 3
#define analogPin A0 // Soundsignal Eingang
LiquidCrystal lcd(12,9,5,0,3,1);

int buttonState = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int sensorValue = 0;
int digital = 0;
//int sensorReading = analogRead (analogPin);
//***variables***variables***variables***variables***variables***variables***variables***variables
//These variables are used by multiplexing and Bit Angle Modulation Code
int shift_out;//used in the code a lot in for(i= type loops
byte anode[4];//byte to write to the anode shift register, 8 of them, shifting the ON level in each byte in the array


byte red0[8], red1[8], red2[8], red3[8];
byte blue0[8], blue1[8], blue2[8], blue3[8];
byte green0[8], green1[8], green2[8], green3[8];


int level=0;//keeps track of which level we are shifting data to
int anodelevel=0;//this increments through the anode levels
int BAM_Bit, BAM_Counter=0; // Bit Angle Modulation variables to keep track of things

//These variables can be used for other things
unsigned long start;//for a millis timer to cycle through the animations

//****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup
void setup(){

SPI.setBitOrder(MSBFIRST);//Most Significant Bit First
SPI.setDataMode(SPI_MODE0);// Mode 0 Rising edge of data, keep clock low
SPI.setClockDivider(SPI_CLOCK_DIV2);//Run the data in at 16MHz/2 - 8MHz
lcd.begin(16,2);
//Serial.begin(9600);// if you need it?
noInterrupts();// kill interrupts until everybody is set up

//We use Timer 1 to refresh the cube
TCCR1A = B00000000;//Register A all 0's since we're not toggling any pins
TCCR1B = B00001011;//bit 3 set to place in CTC mode, will call an interrupt on a counter match
//bits 0 and 1 are set to divide the clock by 64, so 16MHz/64=250kHz
TIMSK1 = B00000010;//bit 1 set to call the interrupt on an OCR1A match
OCR1A=30; // you can play with this, but I set it to 30, which means:
//our clock runs at 250kHz, which is 1/250kHz = 4us
//with OCR1A set to 30, this means the interrupt will be called every (30+1)x4us=124us,
// which gives a multiplex frequency of about 8kHz

// here I just set up the anode array, this is what's written to the anode shift register, to enable each level

anode[0]=B00000001;
anode[1]=B00000010;
anode[2]=B00000100;
anode[3]=B00001000;
// don't hate on how I assigned the values to this register! haha

//finally set up the Outputs
pinMode(buttonPin,INPUT);
pinMode(latch_pin, OUTPUT);//Latch
pinMode(data_pin, OUTPUT);//MOSI DATA
pinMode(clock_pin, OUTPUT);//SPI Clock
//pinMode(blank_pin, OUTPUT);//Output Enable  important to do this last, so LEDs do not flash on boot up
SPI.begin();//start up the SPI library
interrupts();//let the show begin, this lets the multiplexing start



}//***end setup***end setup***end setup***end setup***end setup***end setup***end setup***end setup***end setup***end setup


void loop(){//***start loop***start loop***start loop***start loop***start loop***start loop***start loop***start loop***start loop


//Each animation located in a sub routine
// To control an LED, you simply:
// LED(level you want 0-7, row you want 0-7, column you want 0-7, red brighness 0-15, green brighness 0-15, blue brighness 0-15);
Button();

}//***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop

[edit] korrigiert und als CODE eingestellt. Uwe [/EDIT]

Das "Für Forum formatieren" ist verbuggter Unsinn wie du siehst :slight_smile:

Kopier einfach den Code normal

Der Code ist einfach zu groß :roll_eyes:

#include <LiquidCrystal.h>


#include <SPI.h>


#define latch_pin 2// can use any pin you want to latch the shift registers
#define blank_pin 4// same, can use any pin you want for this, just make sure you pull up via a 1k to 5V
#define data_pin 11// used by SPI, must be pin 11
#define clock_pin 13// used by SPI, must be 13
#define buttonPin  7 // Kippschalter 1
#define buttonPin1 8 // Kippschater 2
#define buttonPin2 10 //Kippschalter 3
#define analogPin A0 // Soundsignal Eingang
LiquidCrystal lcd(12,9,5,0,3,1);

int buttonState = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int sensorValue = 0;
int digital = 0;
//int sensorReading = analogRead (analogPin);
//***variables***variables***variables***variables***variables***variables***variables***variables
//These variables are used by multiplexing and Bit Angle Modulation Code
int shift_out;//used in the code a lot in for(i= type loops
byte anode[4];//byte to write to the anode shift register, 8 of them, shifting the ON level in each byte in the array


byte red0[8], red1[8], red2[8], red3[8];
byte blue0[8], blue1[8], blue2[8], blue3[8];
byte green0[8], green1[8], green2[8], green3[8];


int level=0;//keeps track of which level we are shifting data to
int anodelevel=0;//this increments through the anode levels
int BAM_Bit, BAM_Counter=0; // Bit Angle Modulation variables to keep track of things

//These variables can be used for other things
unsigned long start;//for a millis timer to cycle through the animations

//****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup****setup
void setup(){

SPI.setBitOrder(MSBFIRST);//Most Significant Bit First
SPI.setDataMode(SPI_MODE0);// Mode 0 Rising edge of data, keep clock low
SPI.setClockDivider(SPI_CLOCK_DIV2);//Run the data in at 16MHz/2 - 8MHz
lcd.begin(16,2);
//Serial.begin(9600);// if you need it?
noInterrupts();// kill interrupts until everybody is set up

//We use Timer 1 to refresh the cube
TCCR1A = B00000000;//Register A all 0's since we're not toggling any pins
TCCR1B = B00001011;//bit 3 set to place in CTC mode, will call an interrupt on a counter match
//bits 0 and 1 are set to divide the clock by 64, so 16MHz/64=250kHz
TIMSK1 = B00000010;//bit 1 set to call the interrupt on an OCR1A match
OCR1A=30; // you can play with this, but I set it to 30, which means:
//our clock runs at 250kHz, which is 1/250kHz = 4us
//with OCR1A set to 30, this means the interrupt will be called every (30+1)x4us=124us, 
// which gives a multiplex frequency of about 8kHz

// here I just set up the anode array, this is what's written to the anode shift register, to enable each level

anode[0]=B00000001;
anode[1]=B00000010;
anode[2]=B00000100;
anode[3]=B00001000;
// don't hate on how I assigned the values to this register! haha

//finally set up the Outputs
pinMode(buttonPin,INPUT);
pinMode(latch_pin, OUTPUT);//Latch
pinMode(data_pin, OUTPUT);//MOSI DATA
pinMode(clock_pin, OUTPUT);//SPI Clock
//pinMode(blank_pin, OUTPUT);//Output Enable  important to do this last, so LEDs do not flash on boot up
SPI.begin();//start up the SPI library
interrupts();//let the show begin, this lets the multiplexing start



}//***end setup***end setup***end setup***end setup***end setup***end setup***end setup***end setup***end setup***end setup
void loop(){//***start loop***start loop***start loop***start loop***start loop***start loop***start loop***start loop***start loop


//Each animation located in a sub routine
// To control an LED, you simply:
// LED(level you want 0-7, row you want 0-7, column you want 0-7, red brighness 0-15, green brighness 0-15, blue brighness 0-15);
Button();

}//***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop***end loop



void LED(int level, int row, int column, byte red, byte green, byte blue){ //****LED Routine****LED Routine****LED Routine****LED Routine
//This is where it all starts
//This routine is how LEDs are updated, with the inputs for the LED location and its R G and B brightness levels

// First, check and make sure nothing went beyond the limits, just clamp things at either 0 or 7 for location, and 0 or 15 for brightness
  if(level<0)
  level=0;
  if(level>3)
  level=3;
  if(row<0)
  row=0;
  if(row>3)
  row=3;
  if(column<0)
  column=0;
  if(column>3)
  column=3;  
    if(red<0)
  red=0;
  if(red>15)
  red=15;
  if(green<0)
  green=0;
  if(green>15)
  green=15;
  if(blue<0)
  blue=0;
  if(blue>15)
  blue=15;  
  
  
  //There are 512 LEDs in the cube, so when we write to level 2, column 5, row 4, that needs to be translated into a number from 0 to 511
  
  //This looks confusing, I know...
  int whichbyte = int(((level*16)+(row*4)+column)/8);
  
 
// This next variable is the same thing as before, but here we don't divide by 8, so we get the LED number 0-511
  int wholebyte=(level*16)+(row*4)+column;
//This will all make sense in a sec
 
 //This is 4 bit color resolution, so each color contains x4 64 byte arrays, explanation below:
  bitWrite(red0[whichbyte], wholebyte-(8*whichbyte), bitRead(red, 0));
  bitWrite(red1[whichbyte], wholebyte-(8*whichbyte), bitRead(red, 1));
  bitWrite(red2[whichbyte], wholebyte-(8*whichbyte), bitRead(red, 2)); 
  bitWrite(red3[whichbyte], wholebyte-(8*whichbyte), bitRead(red, 3)); 

  bitWrite(green0[whichbyte], wholebyte-(8*whichbyte), bitRead(green, 0));
  bitWrite(green1[whichbyte], wholebyte-(8*whichbyte), bitRead(green, 1));
  bitWrite(green2[whichbyte], wholebyte-(8*whichbyte), bitRead(green, 2)); 
  bitWrite(green3[whichbyte], wholebyte-(8*whichbyte), bitRead(green, 3));

  bitWrite(blue0[whichbyte], wholebyte-(8*whichbyte), bitRead(blue, 0));
  bitWrite(blue1[whichbyte], wholebyte-(8*whichbyte), bitRead(blue, 1));
  bitWrite(blue2[whichbyte], wholebyte-(8*whichbyte), bitRead(blue, 2)); 
  bitWrite(blue3[whichbyte], wholebyte-(8*whichbyte), bitRead(blue, 3));
  

}//****LED routine end****LED routine end****LED routine end****LED routine end****LED routine end****LED routine end****LED routine end

ISR(TIMER1_COMPA_vect){//***MultiPlex BAM***MultiPlex BAM***MultiPlex BAM***MultiPlex BAM***MultiPlex BAM***MultiPlex BAM***MultiPlex BAM

//This routine is called in the background automatically at frequency set by OCR1A
//In this code, I set OCR1A to 30, so this is called every 124us, giving each level in the cube 124us of ON time
//There are 8 levels, so we have a maximum brightness of 1/8, since the level must turn off before the next level is turned on
//The frequency of the multiplexing is then 124us*8=992us, or 1/992us= about 1kHz


  PORTD |= 1<<blank_pin;//The first thing we do is turn all of the LEDs OFF, by writing a 1 to the blank pin
  //Note, in my bread-boarded version, I was able to move this way down in the cube, meaning that the OFF time was minimized
  //do to signal integrity and parasitic capcitance, my rise/fall times, required all of the LEDs to first turn off, before updating
  //otherwise you get a ghosting effect on the previous level

//This is 4 bit 'Bit angle Modulation' or BAM, There are 8 levels, so when a '1' is written to the color brightness, 
//each level will have a chance to light up for 1 cycle, the BAM bit keeps track of which bit we are modulating out of the 4 bits
//Bam counter is the cycle count, meaning as we light up each level, we increment the BAM_Counter
if(BAM_Counter==8)
BAM_Bit++;
else
if(BAM_Counter==24)
BAM_Bit++;
else
if(BAM_Counter==56)
BAM_Bit++;

BAM_Counter++;//Here is where we increment the BAM counter

switch (BAM_Bit){//The BAM bit will be a value from 0-3, and only shift out the arrays corresponding to that bit, 0-3
//Here's how this works, each case is the bit in the Bit angle modulation from 0-4, 
//Next, it depends on which level we're on, so the byte in the array to be written depends on which level, but since each level contains 64 LED,
//we only shift out 8 bytes for each color
case 0:
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(red0[shift_out]);
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(green0[shift_out]); 
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(blue0[shift_out]);
  break;
case 1:
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(red1[shift_out]);
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(green1[shift_out]); 
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(blue1[shift_out]);
  break;
 case 2:
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(red2[shift_out]);
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(green2[shift_out]); 
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(blue2[shift_out]);
 break;
 case 3:
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(red3[shift_out]);
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(green3[shift_out]); 
 for(shift_out=level; shift_out<level+2; shift_out++)
 SPI.transfer(blue3[shift_out]);
 //Here is where the BAM_Counter is reset back to 0, it's only 4 bit, but since each cycle takes 8 counts,
 //, it goes 0 8 16 32, and when BAM_counter hits 64 we reset the BAM
  if(BAM_Counter==120){
  BAM_Counter=0;
  BAM_Bit=0;
  }
  break;
}//switch_case

SPI.transfer(anode[anodelevel]);//finally, send out the anode level byte

PORTD |= 1<<latch_pin;//Latch pin HIGH
PORTD &= ~(1<<latch_pin);//Latch pin LOW
PORTD &= ~(1<<blank_pin);//Blank pin LOW to turn on the LEDs with the new data

anodelevel++;//inrement the anode level
level = level+2;

if(anodelevel==4)//go back to 0 if max is reached
anodelevel=0;
if(level==8)
level=0;
pinMode(blank_pin, OUTPUT);//moved down here so outputs are all off until the first call of this function
}//***MultiPlex BAM END***MultiPlex BAM END***MultiPlex BAM END***MultiPlex BAM END***MultiPlex BAM END***MultiPlex BAM END***MultiPlex BAM END


void Button(){ buttonState2 = digitalRead(buttonPin2);
delay (100);
if(buttonState2 == HIGH) {
  
rainVersionTwo();
clean();
//delay (1000);


}
if (buttonState2 == LOW) {
   bouncyvTwo();
 clean();
}
}
/*if (((buttonState == LOW) && (buttonState1 == LOW)) &! ((buttonState == HIGH)&& (buttonState1 == HIGH))) {
  
  
 harlem_shake();
clean();

}
}
*/




  

  
  
  
//bouncyv2
void clean(){
  int ii, jj, kk;
    for(ii=0; ii<8; ii++)
  for(jj=0; jj<8; jj++)
  for(kk=0; kk<8; kk++)
  LED(ii,jj,kk,0,0,0);
  
}

Wollte schon nach der loop fragen :slight_smile:

Die Animationen habe Ich nochmal in extra TAB´s abgelegt, weil das ganze zu unübersichtlich wird :astonished:

Wenn der Cube natürlich auf Frequenzen reagieren würde, wäre natürlich noch besser. Aber da eignet sich ja der 8x8x8 noch besser für.

Einen großen sketch kannst Du auch als Anhang mittels Addition Options unter dem Editorfenste anhängen (bis zu 4MByte).
Grüße Uwe

Das wäre jetzt zb. die Animation für den Regen...

void rainVersionTwo(){buttonState = digitalRead(buttonPin), buttonState1 = digitalRead(buttonPin1);
  int x[64], y[64], z[64], addr, leds=64, bright=1, ledcolor, colowheel;
  int xx[64], yy[64], zz[64], xold[64], yold[64], zold[64], slowdown;
  int blau,rot,bunt;
  sensorValue = analogRead(analogPin);
  digital = map(sensorValue, 0,50 , 0,50); // Muss nicht sein, kann aber !
  lcd.setCursor(0,0);
   lcd.print(digital);
  for(addr=0; addr<32; addr++){
    x[addr]=random(3);
    y[addr]=random(3);
    z[addr]=random(3);
    xx[addr]=random(3);
    yy[addr]=random(3);
    zz[addr]=random(3);     
  }
  
  //*********************************LCD Anweisungen************************************
 
  if((buttonState == HIGH) &!(buttonState1==HIGH)){
   lcd.setCursor(0,0);
    lcd.print("Blue-Rain!!");
    //return;
  }
  if ((buttonState1 == HIGH)&! (buttonState == HIGH)){
    lcd.setCursor(7,0);
      lcd.print("Red-Rain");
      //return;
    }
   
   if ((buttonState == LOW)&&(buttonState1 ==LOW)){
     lcd.setCursor(0,0);
      lcd.print("Green-Rain!!");
      //return;
     }
   
    if ((buttonState == HIGH) &&( buttonState1 == HIGH)){
      lcd.setCursor(0,0);
      lcd.print("Rainbow-Rain!!");
      //return;
      }
  delay(3000);
  
  
 //********************************************************************************************
  
  start=millis();
  while(millis()-start<100000000){
  
    
 
  if((buttonState == HIGH) &!(buttonState1==HIGH)){ //************* Button Funktion 1
   
  for(addr=0; addr<leds; addr++){
    LED(zold[addr], xold[addr], yold[addr], 0, 0, 0);

    if(z[addr]<=3)
  LED(z[addr], x[addr], y[addr], 3, 0, 12);
    if(z[addr]==2)
  LED(z[addr], x[addr], y[addr], 10, 0, 15);
    if(z[addr]==1)
  LED(z[addr], x[addr], y[addr], 10, 0, 10);
    if(z[addr]<=0)
  LED(z[addr], x[addr], y[addr], 10, 0, 1);
}}//200


    if ((buttonState1 == HIGH)&! (buttonState == HIGH)){//************** Button Funktion 2
  ;
  for(addr=0; addr<leds; addr++){
    LED(zold[addr], xold[addr], yold[addr], 0, 0, 0);
 
    if(z[addr]==3)
  LED(z[addr], x[addr], y[addr], random(10,15), 0, 0);
    if(z[addr]==2)
  LED(z[addr], x[addr], y[addr], random (10,15), 2, 0);
    if(z[addr]==1)
  LED(z[addr], x[addr], y[addr], random(10,15), 5, 0);
    if(z[addr]<=0)
  LED(z[addr], x[addr], y[addr], random (10,15), 10, 0);
}}//300

   // if(ledcolor>=200&&ledcolor<300){
     if ((buttonState == LOW)&&(buttonState1 ==LOW)){//*****************Button Funktion 3
   //  lcd.setCursor(0,0);
     // lcd.print("Green-Rain!!");
       //delay(10);
for(addr=0; addr<leds; addr++){
    LED(zold[addr], xold[addr], yold[addr], 0, 0, 0);
  
    if(z[addr]==3)
  LED(z[addr], x[addr], y[addr], 0, random(1,16), 10);
    if(z[addr]==2)
  LED(z[addr], x[addr], y[addr], 0, random (1,16), 8);
    if(z[addr]==1)
  LED(z[addr], x[addr], y[addr], 0, random (1,16), 1);
    if(z[addr]<=0)
  LED(z[addr], x[addr], y[addr], 0, random (1,16), 1);
}}
  
    // if(ledcolor>=300&&ledcolor<400){
      if ((buttonState == HIGH) &&( buttonState1 == HIGH)){//*****************Button Funktion 4
      //lcd.setCursor(0,0);
      //lcd.print("Rainbow-Rain!!");
      // delay(10);  
     for(addr=0; addr<leds; addr++){
    LED(zold[addr], xold[addr], yold[addr], 0, 0, 0);
  
    if(z[addr]==3)
  LED(z[addr], x[addr], y[addr], random(1,16),random (1,16) ,random (1,16));
    if(z[addr]==2)
  LED(z[addr], x[addr], y[addr], random(1,16),random (1,16) ,random (1,16));
    if(z[addr]==1)
  LED(z[addr], x[addr], y[addr], random(1,16),random (1,16) ,random (1,16));
    if(z[addr]<=0)
  LED(z[addr], x[addr], y[addr], random(1,16),random (1,16) ,random (1,16)); 
}}
  
 /* if(ledcolor>=400&&ledcolor<500){
     for(addr=0; addr<leds; addr++){
    LED(zold[addr], xold[addr], yold[addr], 0, 0, 0);
  
    if(z[addr]==3)
  LED(z[addr], x[addr], y[addr], 15, 10, 10);
    if(z[addr]==2)
  LED(z[addr], x[addr], y[addr], 15, 12, 12);
    if(z[addr]==1)
  LED(z[addr], x[addr], y[addr],15, 13, 13);
    if(z[addr]<=0)
  LED(z[addr], x[addr], y[addr], 10, 10, 10); 
  
  
}}*/
  ledcolor++;
if(ledcolor>=200)
ledcolor=0;
  
    for(addr=0; addr<leds; addr++){
    xold[addr]=x[addr];
    yold[addr]=y[addr];
    zold[addr]=z[addr];
   } 
  
  
  delay(digital*10);
  
  //for(addr=0; addr<leds; addr++)
  //LED(z[addr], x[addr], y[addr], 0, 0, 0);
    for(addr=0; addr<leds; addr++){
      
      //slowdown = random(8);
      //if(bitRead(z[addr],0))
  z[addr] = z[addr]-1;
  
 // x[addr] = x[addr]+1;
 // y[addr] = y[addr]+1;
  if(z[addr]<random(-100,0)){
    x[addr]=random(4);
    y[addr]=random(4);
    int select=random(4);
    if(select==0){
    xx[addr]=0;
    zz[addr]=random(4);
    yy[addr]=random(4);
    //zz[addr]=0;
    }
    if(select==1){
    xx[addr]=random(4);
    zz[addr]=0;
    yy[addr]=random(4);
    //yy[addr]=0;
    }
    if(select==2){
    xx[addr]=random(4);
    zz[addr]=random(4);
    yy[addr]=0;
    
    
    }    
   z[addr]=3; 
   

  }//-check
  }//add

  
  }//while
  
 
    
lcd.clear();
 
}//rainv2

Soooooooo......habe jetzt ein paar Tage das ein oder andere ausprobiert und habe den Cube jetzt so weit das er je nach Stärke des Analog Signals die Level schaltet und die Farben wechselt.Vielen Dank nochmal für die Ratschläge und Hilfen.

Nun habe Ich mir mal diese FFT und FHT Geschichten angeschaut und wie sollte es anders sein, keine Ahnung wie Ich damit umgehen soll. Was muss Ich dort eingeben oder oder oder. Bin da wohl noch viel zu grün hinter den Ohren was µc angeht =(

Grüße Oliver

hii kannst du ,ir den code schicken ??? bitte den ich brauch das fur ein projekt und ich weis nicht wie das man macht ..... hoffe auf deine hilfe ...

danke :slight_smile:

Der steht hier doch im Thread! Sinnvoller ist es aber, sowas zu lernen anstatt überall zu kopieren. Ein 4x4x4 RGB Led Cube ist aber kein Anfänger Projekt