Paso 11:4 x 4 x 4 código de cubo con cambio de registros, versión de ánodo común
OCT32012 edición cambia para adaptar este programa para trabajar con registros de desplazamiento,
y a trabajar con el cubo de LED de ánodo común. hippynurd
#include / / permite el uso de PROGMEM para almacenar patrones de flash
#define CUBESIZE 4
#define PLANESIZE CUBESIZE * CUBESIZE
#define PLANETIME 3333 / / tiempo de cada plano se muestra en nosotros -> refresco de 100 Hz
#define TIMECONST 20 / / multiplica DisplayTime para obtener ms - = ¿por qué no 100?
Tabla de patrón de LED en PROGMEM - la última columna es tiempo de visualización en unidades de 100ms
TODO esto podría ser mucho más compacto, pero no con la representación del patrón binario
prog_uchar PROGMEM PatternTable [] = {}
parpadea el encendido y apagado
B0001 B0000 B0000, B0000, B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0011 B0000 B0000, B0000, B0011, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0011 B0010, B0000, B0000, B0011, B0010, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0011 B0011 B0000, B0000, B0011, B0011, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0110 B0110 B0000, B0000, B0110, B0110, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0110, B0110, B0000, B0000, B0110, B0110, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0110, B0110, B0000, B0000, B0110, B0110, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0110, B0110, B0000, B0000, B0110, B0110, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0011, B0011, B0000, B0000, B0011, B0011, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0001, B0011, B0111, B0000, B0001, B0011, B0111, B0000, B0000, B0001, B0011, 10,
B0000 B0000 B0000, B0000, B0000, B0011, B0111, B0111, B0000, B0011, B0111, B0111, B0000, B0001, B0011, B0111, 10,
B0000 B0000 B0000, B0000, B0000, B0111, B0111, B0111, B0000, B0111, B0111, B0111, B0000, B0011, B0111, B0111, 10,
B0000 B0000 B0000, B0000, B0000, B0111, B0111, B0111, B0000, B0111, B0111, B0111, B0000, B0111, B0111, B0111, 10,
B0000 B0000 B0000, B0000, B0000, B1110, B1110, B1110, B0000, B1110, B1110, B1110, B0000, B1110, B1110, B1110, 10,
B0000 B1110, B1110, B1110, B0000, B1110, B1110, B1110, B0000, B1110, B1110, B1110, B0000, B0000, B0000, B0000, 10,
B0000 B1110, B1110, B1110, B0000, B1110, B1110, B1110, B0000, B1100, B1110, B1110, B0000, B0000, B0000, B0000, 10,
B0000 B1110, B1110, B1110, B0000, B1100, B1110, B1110, B0000, B1000, B1100, B1110, B0000, B0000, B0000, B0000, 10,
B0000 B1100, B1110, B1110, B0000, B1000, B1100, B1110, B0000, B0000, B1000, B1100, B0000, B0000, B0000, B0000, 10,
B0000 B1000, B1100, B1110, B0000, B0000, B1000, B1100, B0000, B0000, B0000, B1000, B0000, B0000, B0000, B0000, 10,
B0000 B0000, B1000, B1100, B0000, B0000, B0000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000, B1000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B1000 B1000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1000 B1000 B1000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1100 B1000 B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1110, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1110 B0000 B0000, B0000, B0010, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0110 B0000 B0000, B0000, B0011, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0010 B0000 B0000, B0000, B0011, B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0011, B0001, B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0001, B0001, B0001, B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0001, B0001, B0011, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0001, B0111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B1111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B1110, B0000, B0000, B0000, B1000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B1100, B0000, B0000, B1000, B1000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B1000, B0000, B0000, B1100, B1000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1110, B1000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1111, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0001, B0111, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0001, B0001, B0011, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0001, B0001, B0001, B0000, B0001, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0001, B0001, B0000, B0000, B0011, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0111, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1111, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1110, B1000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1100, B1100, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1000, B1110, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1111, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0111, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0011, B0000, B0000, 10,
B0000 B0001, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0001, B0000, B0000, 10,
B0001 B0001, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0011 B0001, B0000, B0000, B0000, B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0111 B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1100, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1110, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B0001, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B0011, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B0111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1100, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1110, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0111 B0111 B0111, B0111, B1000, B1000, B1000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0011 B0011 B0011, B0011, B0100, B0100, B0100, B0100, B1000, B1000, B1000, B1000, B0000, B0000, B0000, B0000, 10,
B0001 B0001, B0001, B0001, B0010, B0010, B0010, B0010, B0100, B0100, B0100, B0100, B1000, B1000, B1000, B1000, 10,
B0001 B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0010, B0010, B0010, B0010, B0100, B0100, B0100, B0100, 10,
B0001 B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0010, B0010, B0010, B0010, 10,
B0001 B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, B0001, 10,
B0010 B0001, B0001, B0001, B0010, B0001, B0001, B0001, B0010, B0001, B0001, B0001, B0010, B0001, B0001, B0001, 10,
B0100 B0010, B0001, B0001, B0100, B0010, B0001, B0001, B0100, B0010, B0001, B0001, B0100, B0010, B0001, B0001, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0010 B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, 10,
B0100 B0100 B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0010 B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, 10,
B0100 B0100 B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0010 B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, 10,
B0100 B0100 B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0010 B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, 10,
B0100 B0100 B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0010 B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, 10,
B0100 B0100 B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0010 B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, 10,
B0100 B0100 B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, B0100, B0100, B0010, B0010, 10,
B1000 B0100 B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, 10,
B0000 B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, B0000, B1100, B0011, B0000, 10,
B0000 B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, B0000, B0011, B1100, B0000, 10,
B0001 B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0000 B0010, B0100, B0000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0000 B0000 B0000, B0000, B0000, B0010, B0100, B0000, B0001, B0010, B0100, B1000, B0001, B0010, B0100, B1000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0010, B0100, B0000, B0001, B0010, B0100, B1000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0010, B0100, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B1000, B0000, B0010, B0000, B1000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B1000, B0000, B0010, B0000, B1000, B0000, B0010, B1000, B0000, 10,
B0000 B0000 B0000, B1000, B0000, B0010, B0000, B1000, B0000, B0010, B1000, B0000, B0000, B0000, B1000, B0000, 10,
B0000 B0010, B0000, B1000, B0000, B0010, B1000, B0000, B0000, B0000, B1000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0010, B1000, B0000, B0000, B0000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000, B1000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0100 B0010, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0110 B0110, B0000, B0000, B0100, B0010, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1001 B0110 B0110, B1001, B0000, B0110, B0110, B0000, B0000, B0100, B0010, B0000, B0000, B0000, B0000, B0000, 10,
B1101 B0111, B1110, B1011, B1001, B0110, B0110, B1001, B0000, B0110, B0110, B0000, B0000, B0100, B0010, B0000, 10,
B1111 B1111 B1111, B1111, B1101, B0111, B1110, B1011, B1001, B0110, B0110, B1001, B0000, B0110, B0110, B0000, 10,
B1111 B1111 B1111, B1111, B1111, B1111, B1111, B1111, B1101, B0111, B1110, B1011, B1001, B0110, B0110, B1001, 10,
B1111 B1111 B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1101, B0111, B1110, B1011, 10,
B1111 B1111 B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, 10,
B1111 B1111 B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1111, B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B1111 B1111 B1111, B1111, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 10,
se trata de un elemento ficticio para el final de la tabla (duración = 0) aka!!! ¡ NO TOQUE!
B0000 B0000 B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 0
};
/*
** Definición de pines de matriz facilita cambiar cómo se cablea el cubo
** Ajustar números aquí hasta que parpadean en orden - L a R, T a B
** Nota que entradas analógicas 0-5 también son salidas digitales 14-19.
** Pin DigitalOut0 (serial RX) y AnalogIn5 se dejan abierta para futuras aplicaciones
*/
Solo una nota para decir que no hacemos las cosas de esta manera ya. Datos se serializan
al pin 7 via 74hc595 shift son controlados los registros y el planes(layers)
por pernos 11,10,9,6. El primer cambio registro controles primero 8 terminales, el
en segundo lugar cambio pins de controles de registro 9-16.
Mirando hacia abajo en el cubo, la matriz de columna pin tiene este aspecto:
16 15 14 13
//
12 11 10 9
//
8 7 6 5
//
4 3 2 1
Mi cubo es ánodo común, lo que significa enviar 5 voltios a la plane(layer) y la tierra
condujo la columna para iluminar al individuo. Este código fue originalmente común cátodo.
ANTIGUO
int LEDPin [] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 14, 15};
int [] PlanePin = {16, 17, 18, 19};
Nuevo
int LEDPin [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int [] PlanePin = {11, 10, 9, 6};
int dataPin = 7; He añadido estos cambio de registro de datos
clockPin INT = 12; Reloj
int latchPin = 13; Cierre
inicialización de
void setup()
{
int pin; contador de bucle
/*
configura pines del LED como salida (activo alto)
para (pin = 0; pines pinMode (LEDPin [pin], salida);
}
*/
configurar los pines para salida serie
{
pinMode (latchPin, salida);
pinMode (clockPin, salida);
pinMode (dataPin, salida);
}
configurar pines plano como salidas (activo bajo)
para (pin = 0; pines pinMode (PlanePin [pin], salida);
}
}
muestra patrón en mesa hasta DisplayTime es cero (y repetir)
void loop()
{
declarar variables
byte PatternBuf [PLANESIZE]; guarda el patrón actual de PatternTable
int PatternIdx;
byte DisplayTime; tiempo * 100ms para mostrar configuración
EndTime largo sin firmar;
plano de int. contador de bucle para actualización de cubo
int patbufidx; índices que byte del buffer patrón
int ledrow; cuenta con LEDs en bucle de actualización
int ledcol; cuenta con LEDs en bucle de actualización
int ledpin; cuenta con LEDs en bucle de actualización
int pinState; pinState se utiliza para enviar la broca correcta al pin de datos
Inicializar PatternIdx al principio de la tabla patrón
PatternIdx = 0;
lazo sobre las entradas de tabla de patrón - mientras DisplayTime > 0
{}
Lee el patrón de PROGMEM y guardar en array
memcpy_P (PatternBuf, PatternTable + PatternIdx, PLANESIZE);
PatternIdx += PLANESIZE;
leer DisplayTime del índice PROGMEM y el incremento de
DisplayTime = pgm_read_byte_near (PatternTable + PatternIdx ++);
calcular EndTime del actual tiempo (ms) y DisplayTime
EndTime = millis() + ((unsigned long) DisplayTime) * TIMECONST;
bucle mientras DisplayTime > tiempo 0 y actual < EndTime
mientras que (millis() < EndTime) {}
patbufidx = 0; reiniciar contador de índice al principio del buffer
lazo sobre planos
para (plano = 0; plano / / desactivar plano anterior (bajo es apagado, alto)
Si (plano == 0) {}
digitalWrite (PlanePin [CUBESIZE-1], LOW);
} else {}
digitalWrite (PlanePin [plano-1], LOW);
}
/*
datos actuales de patrón plano de carga en puertos
ledPin = 0;
para (ledrow = 0; ledrow de (ledcol = 0; ledcol digitalWrite (LEDPin [ledpin ++], PatternBuf [patbufidx] & (1 << ledcol));
}
patbufidx ++;
}
*/
He utilizado código de shiftout, rehacer para serializar los datos del plano
latchPin de tierra y mantenga bajo para mientras usted esté transmitiendo
digitalWrite (latchPin, 0);
EM se muda
ledPin = 0;
para (ledrow = 0; ledrow de (ledcol = 0; ledcol
digitalWrite (clockPin, 0);
digitalWrite (dataPin, PatternBuf [patbufidx] & (1 << ledcol));
Si (PatternBuf [patbufidx] & (1 << ledcol))
{
pinState = 0; Estos bits para adaptarse a su conductor común de cubos (cátodo o ánodo) del tirón
}
otra cosa
{
pinState = 1; Estos bits para adaptarse a su conductor común de cubos (cátodo o ánodo) del tirón
}
Establece el pin en alto o bajo dependiendo de pinState
digitalWrite (dataPin, pinState); Esto es donde se envían los datos para el registro de desplazamiento.
registro de cambios de bits en carrera ascendente de pin de reloj
digitalWrite (clockPin, 1);
ledPin ++;
}
patbufidx ++;
}
digitalWrite (latchPin, 1);
Activar actual plano (plano de alta para el)
digitalWrite (PlanePin [avión], alto);
retrasar PLANETIME nos
delayMicroseconds (PLANETIME);
} / / avión
} / / mientras} mientras (DisplayTime > 0); leer patrones hasta el momento = 0 que indica el final
}