0% found this document useful (0 votes)
55 views5 pages

Codigo Arduinocuboled 5 X 5 X 5

This document contains Arduino code for a 5x5x5 LED cube that recognizes music. The code initializes 25 LED pins as outputs, reads analog music input from pin A0, maps the input value to control which LEDs are turned on at different volume thresholds, and displays the input value over serial. The cube lights up different patterns of LEDs based on the music volume to visualize the sound.

Uploaded by

baron_tail
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views5 pages

Codigo Arduinocuboled 5 X 5 X 5

This document contains Arduino code for a 5x5x5 LED cube that recognizes music. The code initializes 25 LED pins as outputs, reads analog music input from pin A0, maps the input value to control which LEDs are turned on at different volume thresholds, and displays the input value over serial. The cube lights up different patterns of LEDs based on the music volume to visualize the sound.

Uploaded by

baron_tail
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

// Cubo led de 5x5x5. // Codigo libre. Hecho para reconocer musica. MONO. // Hecho para ciencias experimentales.

int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int C1 = 39; //Empezamos con reconocer los pines C2 = 32; C3 = 38; C4 = 31; C5 = 41; C6 = 44; C7 = 27; C8 = 33; C9 = 26; C10 = 28; C11 = 23; C12 = 43; C13 = 45; C14 = 25; C15 = 37; C16 = 24; C17 = 29; C18 = 35; C19 = 46; C20 = 40; C21 = 36; C22 = 42; C23 = 34; C24 = 30; C25 = 22; L1 = 1; L2 = 2; L3 = 3; L4 = 4; L5 = 5;

void setup() { pinMode(C1, OUTPUT); //Damos de alta las salidas pinMode(C2, OUTPUT); //de voltaje pinMode(C3, OUTPUT); pinMode(C4, OUTPUT); pinMode(C5, OUTPUT); pinMode(C6, OUTPUT); pinMode(C7, OUTPUT); pinMode(C8, OUTPUT); pinMode(C9, OUTPUT); pinMode(C10, OUTPUT); pinMode(C11, OUTPUT); pinMode(C12, OUTPUT); pinMode(C13, OUTPUT); pinMode(C14, OUTPUT); pinMode(C15, OUTPUT); pinMode(C16, OUTPUT); pinMode(C17, OUTPUT); pinMode(C18, OUTPUT); pinMode(C19, OUTPUT); pinMode(C20, OUTPUT); pinMode(C21, OUTPUT); pinMode(C22, OUTPUT); pinMode(C23, OUTPUT); pinMode(C24, OUTPUT);

pinMode(C25, OUTPUT); pinMode(L1, OUTPUT); pinMode(L2, OUTPUT); pinMode(L3, OUTPUT); pinMode(L4, OUTPUT); pinMode(L5, OUTPUT); Serial.begin(9600);//Inicia el reconocimiento analogico analogReference(INTERNAL1V1);//Reconocimento de 1.1 Volts } void loop() { //inicia programa int val = analogRead(A0); //leer entrada analogica delay(1); //tiempo entre lectura val = constrain(val, 0, 150); //limitar los valores int music = map(val, 150, 0, 1024, 0);// mapear los valores digitalWrite(L1,HIGH);//inicia el poder de las 5 capas digitalWrite(L2,HIGH); digitalWrite(L3,HIGH); digitalWrite(L4,HIGH); digitalWrite(L5,HIGH); if(music >(60))//if= en caso de.... valor de la musica { digitalWrite(C1,LOW);//valor menor digitalWrite(C2,LOW); digitalWrite(C3,LOW); digitalWrite(C4,LOW); digitalWrite(C5,LOW); digitalWrite(C6,LOW); digitalWrite(C7,LOW); digitalWrite(C8,LOW); digitalWrite(C9,LOW); digitalWrite(C10,LOW); digitalWrite(C11,LOW); digitalWrite(C12,LOW); digitalWrite(C13,HIGH); digitalWrite(C15,LOW); digitalWrite(C14,LOW); digitalWrite(C15,LOW); digitalWrite(C16,LOW); digitalWrite(C17,LOW); digitalWrite(C18,LOW); digitalWrite(C19,LOW); digitalWrite(C20,LOW); digitalWrite(C21,LOW); digitalWrite(C22,LOW); digitalWrite(C23,LOW); digitalWrite(C24,LOW); digitalWrite(C25,LOW); }

if(music >(120)) { digitalWrite(C1,LOW); digitalWrite(C2,LOW);

digitalWrite(C3,LOW); digitalWrite(C4,LOW); digitalWrite(C5,LOW); digitalWrite(C6,LOW); digitalWrite(C7,HIGH); digitalWrite(C8,LOW); digitalWrite(C9,HIGH); digitalWrite(C10,LOW); digitalWrite(C11,LOW); digitalWrite(C12,LOW); digitalWrite(C13,HIGH); digitalWrite(C15,LOW); digitalWrite(C14,LOW); digitalWrite(C15,LOW); digitalWrite(C16,LOW); digitalWrite(C17,HIGH); digitalWrite(C18,LOW); digitalWrite(C19,HIGH); digitalWrite(C20,LOW); digitalWrite(C21,LOW); digitalWrite(C22,LOW); digitalWrite(C23,LOW); digitalWrite(C24,LOW); digitalWrite(C25,LOW); } if(music >(180)) { digitalWrite(C1,HIGH); digitalWrite(C2,LOW); digitalWrite(C3,LOW); digitalWrite(C4,LOW); digitalWrite(C5,HIGH); digitalWrite(C6,LOW); digitalWrite(C7,HIGH); digitalWrite(C8,LOW); digitalWrite(C9,HIGH); digitalWrite(C10,LOW); digitalWrite(C11,LOW); digitalWrite(C12,LOW); digitalWrite(C13,HIGH); digitalWrite(C15,LOW); digitalWrite(C14,LOW); digitalWrite(C15,LOW); digitalWrite(C16,LOW); digitalWrite(C17,HIGH); digitalWrite(C18,LOW); digitalWrite(C19,HIGH); digitalWrite(C20,LOW); digitalWrite(C21,HIGH); digitalWrite(C22,LOW); digitalWrite(C23,LOW); digitalWrite(C24,LOW); digitalWrite(C25,HIGH); }

if(music >(240))

{ digitalWrite(C1,HIGH); digitalWrite(C2,LOW); digitalWrite(C3,LOW); digitalWrite(C4,LOW); digitalWrite(C5,HIGH); digitalWrite(C6,LOW); digitalWrite(C7,HIGH); digitalWrite(C8,HIGH); digitalWrite(C9,HIGH); digitalWrite(C10,LOW); digitalWrite(C11,LOW); digitalWrite(C12,HIGH); digitalWrite(C13,HIGH); digitalWrite(C15,LOW); digitalWrite(C14,HIGH); digitalWrite(C15,LOW); digitalWrite(C16,LOW); digitalWrite(C17,HIGH); digitalWrite(C18,HIGH); digitalWrite(C19,HIGH); digitalWrite(C20,LOW); digitalWrite(C21,HIGH); digitalWrite(C22,LOW); digitalWrite(C23,LOW); digitalWrite(C24,LOW); digitalWrite(C25,HIGH); }

if(music >(300)) { digitalWrite(C1,HIGH); digitalWrite(C2,HIGH); digitalWrite(C3,HIGH); digitalWrite(C4,HIGH); digitalWrite(C5,HIGH); digitalWrite(C6,HIGH); digitalWrite(C7,HIGH); digitalWrite(C8,HIGH); digitalWrite(C9,HIGH); digitalWrite(C10,HIGH); digitalWrite(C11,HIGH); digitalWrite(C12,HIGH); digitalWrite(C13,HIGH); digitalWrite(C15,HIGH); digitalWrite(C14,HIGH); digitalWrite(C15,HIGH); digitalWrite(C16,HIGH); digitalWrite(C17,HIGH); digitalWrite(C18,HIGH); digitalWrite(C19,HIGH); digitalWrite(C20,HIGH); digitalWrite(C21,HIGH); digitalWrite(C22,HIGH); digitalWrite(C23,HIGH); digitalWrite(C24,HIGH); digitalWrite(C25,HIGH);

Serial.println(music);//mostrar valores delay(1);//refresh de mostreo

}// fin de el programa.

You might also like