Una matriz de LEDs consiste en un arreglo de LEDs que pueden ser encendidos y apagados individualmente desde un microntrolador. Pueden pensar en ella como una pantalla de pocos pixeles en los cuales pueden presentar gráficos y textos, tanto estáticos como en movimiento.
Pines de conexión de una matriz de 5×7
Existen muchas aplicaciones para este tipo de displays. Uno de los ejemplos más interesantes que conozco es el Bitman desarrollado por Ryota Kuwakubo bajo Maywa Denki.
La figura reacciona cuando el objeto es sacudido o inclinado.
Por otro lado, las obras “ambiguos icons” de Jim Campbell hacen uso de matrices de LEDs mucho mayores. Empleando como fuente de partida imágenes de video, Campbell las “filtra” y las reduce al universo de los LEDs. En la exposición Fantasmagoría curada por José Roca y presentada en Bogotá en el año 2007 se incluía la obra “Library” donde una matriz de LEDs producía la ilusión de sombras en movimiento sobre una imagen fotográfica. En wmmna pueden encontrar algunos comentarios que hice al respecto.
Library (2004).
**********
Conexión
El siguiente gráfico presenta una matriz de 5×7 LEDs, donde las columnas corresponden a los cátodos (deben ir conectados a tierra) y las filas corresponden a los ánodos (deben ir conectados a voltaje).
Matriz de 5×7 con columnas de cátodos
Para encender un LED específico debe ubicarse la interesección entre la columna y la línea correspondiente. Por ejemplo, para encender el LED que se muestra en la figura siguiente, la columna 3 (C3) debe ser conectada a tierra (a través de una resistencia de 220 ohm) mientras que la fila 5 (R5) es conectada a voltaje (5v).
Ejemplo
/* Ejercicio matriz de LEDs 5x7: Una bolita desciende por la primera columna y luego asciende por la columna siguiente. Al llegar a la última línea se devuelve de igual manera. Preparado para el taller dictado en mayo-junio del 2009 Educación Continua, Facultad de Artes, Pontificia Universidad Javeriana a. tamayo laimagendelmundo@yahoo.ca www.thepopshop.org junio 02 - 2009 bogotá ********************************************************************************* Columns as cathods 5x7 LED Matrix Matrix pin #s - 13 3 4 10 6 | | | | | | | c1 c2 c3 c4 c5 9 - r1 O O O O O 14 - r2 O x O O O 8 - r3 O O O O O 12 - r4 O O O O O 1 - r5 O O O O O 7 - r6 O O O O O 2 - r7 O O O O O O indicates LED is off, x LED is on x : c2 LOW, r2 HIGH */ //Arduino pin assignment int c1 = 6; // pin 6 is assigned to column 1 int c2 = 2; // pin 2 is assigned to column 2 int c3 = 3; // pin 3 is assigned to column 3 int c4 = 4; // pin 4 is assigned to column 4 int c5 = 5; // pin 5 is assigned to column 5 int r1 = 7; // pin 7 is assigned to row 1 int r2 = 8; // pin 8 is assigned to row 2 int r3 = 9; // pin 9 is assigned to row 3 int r4 = 10; // pin 10 is assigned to row 4 int r5 = 11; // pin 11 is assigned to row 5 int r6 = 12; // pin 12 is assigned to row 6 int r7 = 13; // pin 13 is assigned to row 7 int Columns[] = {c1, c2, c3, c4, c5}; // these pins must be set to LOW to turn the LEDs on, we'll do that in the loop int Rows[] = {r1, r2, r3, r4, r5, r6, r7}; // these pins must be set to HIGH to turn the LEDs on, we'll do that in the loop boolean leftToRight; // variable to determine the direction of the ball (lef to right or right to left) boolean goingDown; // variable to determine if the ball is bouncing down or up void setup(){ // all pins are declared as OUTPUTS // declares columns as OUTPUTS for (int i=0; i<=4; i++){ // remember that arrays are 0 index pinMode (Columns[i], OUTPUT); } // declares rows as OUTPUTS for (int i=0; i<=6; i++){ pinMode (Rows[i], OUTPUT); } // makes sure all columns are set to HIGH, so no LED is turn on initialy for (int i=0; i<=4; i++){ digitalWrite (Columns[i], HIGH); } leftToRight = true; // when the program starts the ball is moving from left to right goingDown = true; // when the program starts the ball is moving down } void loop(){ // if the ball is moving from left to right if (leftToRight == true){ // for loop that makes the ball advance in the columns for (int j = 0; j <= 4; j++){ digitalWrite (Columns[j], LOW); if (goingDown == true){ for (int i = 0; i <= 6; i++){ digitalWrite(Rows[i], HIGH); delay(100); // waits 100 miliseconds before moving to the next position digitalWrite(Rows[i], LOW); if (i == 6){ goingDown = false; } } digitalWrite(Columns[j], HIGH); } else if (goingDown == false) // ball is going up { for (int i = 6; i >= 0; i--){ digitalWrite(Rows[i], HIGH); delay(100); // waits 100 miliseconds before moving to the next position digitalWrite(Rows[i], LOW); if (i == 0){ goingDown = true; } } } digitalWrite(Columns[j], HIGH); if (j == 4){ leftToRight = false; } } } else // the ball is moving from right to left for (int j = 3; j >= 0; j--){ // try with j = 4 to see the difference digitalWrite (Columns[j], LOW); if (goingDown == true){ for (int i = 0; i <= 6; i++){ digitalWrite(Rows[i], HIGH); delay(100); // waits 100 miliseconds before moving to the next position digitalWrite(Rows[i], LOW); if (i == 6){ goingDown = false; } } digitalWrite(Columns[j], HIGH); } else if (goingDown == false) // ball is going Up { for (int i = 6; i >= 0; i--){ digitalWrite(Rows[i], HIGH); delay(100); // waits 100 miliseconds before moving to the next position digitalWrite(Rows[i], LOW); if (i == 0){ goingDown = true; } } } digitalWrite(Columns[j], HIGH); if (j == 0){ leftToRight = true; } } }
Otros ejemplos
Acelerómetro y matriz de LEDs de 8×8 (Tom Igoe)
Arduino controlando una matriz de LEDs de 8×8 a través del integrado MAX7219 (Bryan Chung).
Pong (Telebolito) implementado en dos matrices de 8×8 y usando Arduino Mega. Presenta también la versión para Processing (Tom Igoe).
______
Creado: 6 de junio, 2009
Actualizado: 27 de junio, 2009
a. tamayo