Você está na página 1de 176

LED cubo de 8x8x8 - Parte 1, Teora.

Por lo que desea un cubo de LED y decidi hacer su propia? ! Yo lo he hecho, y quiero
ayudarte Esta es la parte 1 , la teora de la electrnica que vamos a utilizar y cmo un cubo
obras. Un vdeo rpido:

Hay muchos instructables sobre este tema, sin embargo la mayora de ellos son de personas que
haban partes 'por ah' y tambin asumir un cierto conocimiento de la electrnica. Asumo nada de
eso! Yo se supone que tiene unArduino sin embargo. stos son grandes para los principiantes as
que si usted no tiene uno, comprar uno! Usted puede obtener una buena copia de un UNO por
alrededor de 15 o un nano de alrededor de 10 (no he probado el nano an). Antes de empezar a
bucear, este proyecto isnt muy barato ni rpido. He comprado 600 de LED, es bueno tener
repuestos. Yo recomiendo que stas caigan en ebay, usted debera ser capaz de obtener 600 por
menos de 15 . De hecho, me compr todos mis componentes de eBay, los minoristas de
componentes electrnicos en el Reino Unido parecen solamente como pedidos de ms de 30 y el
resto de los componentes cuestan menos que eso.

Un cubo de LED terminado (Sin Circuitos)


Ahora, en la forma de un cubo se compone y se controla! Usted necesita tener 8 capas, compuesto
por 8 filas y 8 columnas. As que si tomamos una capa, que es de 64 LEDs. Tenemos el control de
estos utilizando registros de desplazamiento. Un registro de desplazamiento es un componente
que tiene dos entradas principales, un reloj y una entrada de datos. Cuando el reloj se mueve de un
alto voltaje a un mnimo de uno, el valor de la entrada de datos (alta tensin o baja) se toma y se
almacena en el primer pasador. El valor desde el primer pasador se toma y se pone en el segundo y
as sucesivamente. El valor en el ltimo pasador se puso en un perno a menudo llamado Q'H. Esto
puede ser tomado por el siguiente registro de desplazamiento y la puso sobre el pasador 1 de dicho
registro. De esta manera podemos enlazar muchos registros de desplazamiento en una lnea y acaba
en cascada los datos en la lneaMediante el uso de este mtodo en cascada podemos utilizar slo
tres pasadores (datos, reloj y el pestillo - Ms acerca de enganche posterior) para controlar todo el
patrn de uno capa. un 74HC595 (el registro utilic) tambin tiene un pestillo. Esto significa que los
datos almacenados en el registro no es en realidad 'muestra' de las patillas del registro de
desplazamiento hasta que el pasador se retira de una baja a una alta tensin. Tener un pestillo es
bueno para nuestro cubo, significa que podemos cambiar de puesto el patrn de los LED que se
enciende en el prximo "marco", mientras que el LED de la ltima trama permanecer
encendido Quieres un buen artculo sobre registros de desplazamiento? Haga clic aqu.

4 capas de un cubo LED

As que usted est pensando, grande, esto es, 64 LEDs controlados, pero quiero un cubo! Bueno,
porque nuestro microcontrolador y registro de desplazamiento combinado puede cambiar los LED
muy rpido, slo tiene que utilizar la multiplexacin. Es decir, el proceso de convertir algo encendido
y apagado muy rpido, por lo que parece ser siempre encendido. Al cambiar los datos para una capa
y 'encender' esa capa. A continuacin, el cambiar los datos para la siguiente capa, la desconexin de
la capa actual, enganche los datos de la prxima capa, 'encender' la capa siguiente y repetir muy
rpido, podemos iluminar todo el cubo, al mismo tiempo, con diferentes patrones de cada capa! Por
lo tanto, es la siguiente:
1. Cambiar de puesto de datos para la siguiente capa en registros de desplazamiento
2. Desactive la capa anterior (por lo que sus LEDs no se encienden)
3. retencin de datos (por lo que se muestra en las patillas de registro de desplazamiento)
4. Encienda siguiente capa, por lo que los LED de la siguiente capa se encienden
5. Goto 1
Hacer esto lo suficientemente rpido, y usted no ser capaz de decir qu capa est encendida y que
no es, simplemente todo parecern estar iluminado con su patrn correcto! Para simplificar, no hizo
uso de un chip para controlar el capas, slo usado 8 pines en mi Arduino. Si desea utilizar un chip, he
ledo funciona el decodificador de 3 a 8 74HC238 lnea. Esta toma de datos binarios en tres
pasadores (por ejemplo, 101, o alto, bajo, alto) y convierte el PIN correspondiente alta (pin 5, en este
caso). La razn por la que desea que se debe a que las capas se 'encienden' cuando estn
conectados a tierra. Para ello tenemos que utilizar un transistor NPN. Puede obtener 8 transistores en
un chip buen nombre de array de Darlington, o ULN2803, como antes! Un transistor es como un
interruptor electrnico. Cuando se aplica una pequea corriente a su base, una ms grande puede
fluir a travs de su colector a su emisor. El transistor Darlington tiene un emisor comn (todos los
emisores estn conectados a la misma pin). As que utilizamos son Arduino, o 74HC238 para aplicar
un alto a la base del transistor conectado a la capa que queremos ser 'encendido'. Ese es el final
parte 1! Para la parte 2, Haga clic aqu para saltar directamente a la parte 3 (Cdigo), haga clic aqu!

Ver comentarios
GovindEl 31 de de mayo de 2014 a 12:15

Hola Liam Jackson,


he seguido todas sus instrucciones y casi terminado mi cubo ... todo lo que tengo conmigo hoy se
completa condujo cubo, los registros de desplazamiento [74HC595] 330 10 I + K resistentes, Arduino UNO
... le PLS proporcionarme esquemas del cubo ...
tambin quisiera saber si hay otros componentes, si es necesario ... gracias

LED 8x8x8 Cubo - Parte 2, Construccin

Esta es la parte 2 del tutorial cubo de LED que estoy escribiendo, para la parte 1 . Clic aqu vamos a
empezar con una lista de partes: una plantilla (se puede hacer de la tarjeta) soldadura (mucha de ella
he usado ms de 2 baeras, as. comprar un carrete) Algunos alambre rgido (para reforzar las
capas) Algunos cable no tan rgido de alambre / cinta cable / alarma (para conectar los LEDs a los
circuitos) al menos 512 LEDs que trabajan por lo menos 8 registros de desplazamiento (que utilizan
74HC595s) 64 Resistencias para los LEDs 8 resistencias para levantar las capas (10K debe ser
fino) Algunos condensadores (puede no ser necesario con Arduino). para construir el cubo, primero
hay que construir una plantilla o plantilla, esta ser utilizada para mantener los LEDs en su lugar
mientras la construccin de las capas. Constru la mina de algn cortar el cartn de la caja, si usted
tiene las herramientas que puede utilizar la madera! Medir la distancia que desea entre sus
LEDs. Las capas estn bsicamente hechas de una malla de las piernas "suelo" de los LEDs, que
tienen que ser doblado en un ngulo derecho. La pierna del suelo es el ms corto.Asegrese de que
haya suficiente solapamiento de la pierna doblada para soldarlos juntos. La otra pierna (ms largo)
debe pegarse directamente hacia arriba (por ahora). Con cartn, me encontr con un lpiz estndar
HB empuj directamente a travs de hecho un agujero del tamao excelente para LEDs de 5 mm! La
primera fila tendr todas las patas apuntando hacia la derecha, con una adherencia de la final. No te
cortarlo, necesitamos eso! A continuacin, hacer las columnas, con las piernas apuntando hacia
arriba hacia la primera fila y la ltima etapa de la columna de ser conjunta para las piernas en la
primera fila.
Los comienzos de una capa de cartn en mi plantilla. Diseado y listo para soldar!

Ahora debera ser capaz de aplicar tierra al punto que sobresale y 5v (o lo que su LED es, usar una
resistencia) para cada pierna hacia arriba. Si un LED no se ilumina puede ser que necesite
intercambiando. Ms fcil de hacerlo ahora que despus! El alambre rgido debe ser cortado a la
anchura de una fila luego se enderez. Separarla (como si estuviera tratando de estirarlo) muy duro
con dos pares de pinzas o una herramienta similar debe conseguir que sea muy recta. Soldar a cada
columna en la fila del medio y la ltima fila. Al soldar las capas, Don 't tiene que preocuparse de las
articulaciones siendo increble. Mientras que sostienen las piernas sin ser frgil que debe estar
bien! Usted no quiere manchas masivas de soldadura por todo el cubo. Niza articulaciones brillantes
delgadas deben ser las mejores. Limpiar su soldador a menudo! Tambin, asegrese de que tiene
algo de ventilacin o los humos de flujo que puede dar un dolor de cabeza y hacer que se sienta
enfermo. Voy a hacer otro blog sobre mi campana extractora de fabricacin casera. Para obtener la
capa de la plantilla simplemente tire suavemente hacia arriba las piernas pegadas y que debera
levantar a cabo. No se moleste en tratar de empujar a travs del otro lado. Siempre se puede
enderezar hasta ms tarde. No se preocupe si todos sus piernas no estn pegando hacia arriba.

Dos capas soldadas entre s, que no han recortado el alambre rgido todava.
Una vez que usted tiene 8 capas, es hora de unirse a ellos juntos. Usted tendr que doblar las
piernas alrededor de la bombilla del LED arriba, para soldarlos a la pierna hacia arriba de las LED
directamente sobre ella. Si no doblar la pierna adecuadamente las capas no se quedarn
directamente uno encima del otro y su cubo parecer torcido. Puede doblar el cubo un poco despus
de su hecho, pero no demasiado! Hay muchas maneras de doblar las piernas, he elegido para doblar
la pierna entera en una direccin, a continuacin, utilizar el dedo para doblar de nuevo hacia el
interior para hacer contacto con la vertical pata del LED arriba. Es posible que desee hacer lo que
hice y hacer un cubo de 3x3x3 'prctica'. que slo utiliza 27 LEDs y que ni siquiera tienen que
alambre si arriba (lo hice, para poner a prueba las ideas).

Mi cubo de 3x3x3 Prctica

El cubo de la prctica es posible que vea que soldar cada cable desde el fondo del cubo a una
resistencia y luego una cabecera. No importa lo rpido que estaba con el pasador este derretido el
encabezado de plstico hacindolos intiles. Para la cosa real acabo soldadas una resistencia al
cable y poner el resistor en la protoboard.

Se puede ver cmo Sold las capas, y mi pobre soldadura - Su mejorado mucho haciendo este proyecto!
Me pareci ms fcil soldar el cubo al revs. Haciendo la capa superior en primer lugar, escoger su
capa ms bonita en busca de esto, es la gente que uno vea! Para mantener la capa en su lugar
mientras soldarlo, hacer un "bloque" de papel o de cartn para contener la capa a la altura
adecuada. Asegrese de que sea el nivel, y luego soldar las esquinas. A continuacin, puede tirar del
"bloque" y soldar el resto. He utilizado una mezcla de mi dedo, un lpiz y unas pinzas de punta de
aguja para asegurarse de que la pierna toca la capa por encima de ella. Luego me hizo la tarjeta de
control. He encontrado este gran tablero en Maplin que puede caber 8 74HC595 en l. Para saber
cmo conectar los registros de desplazamiento, echar un vistazo
aqu: http://bildr.org/2011/02/74hc595/ Bsicamente, conectar todos los pines de reloj en conjunto,
todos los pasadores de retencin juntos y correr el pasador en Q'H el pin de datos de la siguiente. El
pin de datos registra por primera vez se conecta a la placa Arduino, tambin lo hace el reloj y el
pasador. Conectar todos de la VCC a 5V y masa de tierra. Asimismo, deber conectar todos los pines
del "claras serie 'a alta (VCC) y la totalidad de la OE (salida de habilitacin) pines a tierra. Si no lo
hace obtendr un comportamiento extrao, o sus registros no funcionar. Se pueden utilizar
diferentes cable de color, en realidad lo recomiendo, pero slo compr un color.

Cada 'fila' del cubo tiene su propio registro de desplazamiento. Cada pata de la fila est conectado a
un resistor entonces a la salida en el registro de desplazamiento. La resistencia debe hacer que la
corriente del LED tira abajo 6mA, porque eso es lo que el registro de desplazamiento puede hacer
frente. Si usted no tiene un multmetro y algunas resistencias para probar. Algo as como 330ohm
debera ser suficiente. He conectado el ms cercano LED para el tablero de QH (no Q'H) y la que
est ms a la garanta de la calidad (y todos los que estn en el medio, obviamente). Ya que estos no
son soldados, que fcilmente se pueden mover. Esto tambin se puede 'bodged' en el software si lo
conecta divertida y no se puede cambiar. Cada "capa" (recuerda la pierna que dejamos que salen?)
Necesita conectarse a los pines de salida del transistor Darlington. Siempre ver la hoja de datos de
Farnell (clic aqu)Cada capa se conecta a una "salida" (la hoja de datos) los llama salidas de
transistor Darlington. A continuacin os adjunto cada "entrada" a un pin digital del Arduino. El
conector de tierra va al suelo (DUH!) Y el pasador comn va a VCC. No consumo digital de 0 1, que
son de serie. As digital de 2-10 son los pines de seleccin de capa.
Heres que muestra la segunda placa.
Los condensadores en mi tabla probablemente no son necesarios. (Hay un 1000uF, 100uF y 10uF)
Tambin he visto personas ponen muy pequeos condensadores cermicos entre VCC y tierra junto
a cada registro de desplazamiento.Los datos, reloj y pasadores de retencin van al Arduino 11, 13 y
10, respectivamente. Ellos son los que el 74HC595 'biblioteca' SPI he encontrado usos. Eso es todo
para la parte 2, parte 3 es un software! Para la parte 3, haga clic aqu O de la Parte 1, haga clic
aqu

1.

Alfredo Ardia11 de octubre de 2012 14:29

Hola, este blog es genial! Tengo una pregunta: Quiero usar MaxMSP para controlar el cubo, he
encontrado una gua para utilizar 3 595 y controlarlo:
http://little-scale.blogspot.co.uk/2008/01/three-595- shift-registers.html
con el boceto al final de la pgina que puedo utilizar MaxMSP para controlar todos los LED, cmo puedo
modificar esta skatch para controlar el cubo 8x8x8?
Adems no he comprender lo que hacen los pines de Arduino conectados a la ULN2803
Respuesta

2.

Liam Jackson11 de octubre de 2012 16:07


Est bien, no s qu es exactamente MaxMSP, pero creo que el ejemplo se aplica a este obtendra
grande, rpido.
Para el control de una sola capa de un cubo que haba necesidad de modificarlo para apagar 8 bytes en
lugar de 3.

Para controlar todo 8 capas, el ULN2803 entra, que no tienen que utilizar el ULN2803 (en realidad, yo no
lo recomiendo ya) se puede utilizar slo 8 transistores NPN normales capaces de hundir la corriente
suficiente para 64 LEDs.

Bsicamente, aplicar el transistor para cambiar cada capa, una a la vez.


As que se pone el patrn para la que desea en la primera capa del cubo hacia el 595 y utilizando los
transistores para cambiar en esa capa. el LED
a continuacin, se pone el patrn para el la segunda capa a cabo en la dcada de 595, y apague la
primera capa, pestillo de sus de 595 y el interruptor en la segunda capa.

Repetir una y otra para los 8 capas muy rpidamente (al menos 25 veces por segundo) y sus ojos se
engaarle para que pensando en los 8 capas tienen un patrn diferente mostrando al mismo tiempo.

para controlar un cubo desde un PC que me gustara escribir cdigo arduio para contener 64 bytes (un bit
por cada LED) y mostrar que en el cubo. Eso se llama un marco. A continuacin tiene un cdigo de serie
para recibir 64 bytes (un marco) y actualizar la matriz de modo que el Arduino se mostrar el nuevo marco
en el cubo.
Respuesta
3.

Alfredo Ardia11 de octubre de 2012 17:34

ok, as que tengo que aadir 5 bytes para mi bosquejo: -; ...; datos4 bytes; datos5 bytes; ...; Data8 bytes; -
a continuacin, en el bucle: ; ...; datos4 = Serial.read (); ....; Data8 = Serial.read (); - la shiftout ser : ; ...;
SHIFTOUT (pinDatos, pinReloj, datos5); ....; SHIFTOUT (pinDatos, pinReloj, Data8); ahora tengo que
aadir ms? tengo entender lo que hace el LSN o NPN, pero yo no " t understend cmo controlar it..what
son las cadenas de croquis que lo controla? (lo siento por toda esta cuestin y la mala Ingls, pero soy un
novato ..) muchas gracias
Respuesta

4.

Rajesh GjEl 31 de de agosto de 2014 a 10:17

soy muy feliz por su tutorial .pero me enfrentaba a un problema de alimentacin es decir, todos los LED se
ilumina con baja intensidad .what es remedio para este problema .i necesitar su ayuda ....
Respuesta
5.

Rahul Sahu9 de julio de 2016 a 21:40

Seor, puedes ayudarme. slo quiero saber que en la resistencia de tirar hacia arriba (10K ohmios)
seccin que se haya conectado un extremo de los pasadores ULN2803 y entre los que hay cables azules
que son los pines de la capa del cubo, qu pasa con el otro extremo de resistencias donde est
conectado ? est todo junto conectado a VCC o tierra pines de Arduino
respuestas
1.

Liam Jackson18 de de julio de 2016 a 19:41


Ha, buenos ojos! Esas resistencias de 10k estn conectados a VCC para tirar de las capas alta cuando no
es el turno de esa capa.

Yo estaba viendo una representacin dbil de la capa 'iluminado' en la capa 'apagado' que me pareci que
puede ser debido a la capa de "flotante". Sin embargo, fue probablemente slo 'purga luz "porque tengo
LEDs claros.

Estoy bastante seguro de que no los necesita!

2.
Rahul Sahu23 de de julio de 2016 a 23:05

Es necesario para conectar cualquier 0,1 uF condensador a travs del pasador y maquinado para reducir
el ruido. Para el vdeo de los LED no se iluminan con claridad hasta que es debido a algn ruido o algo
ms. Alguna solucin??

3.

Liam Jackson23 de de julio de 2016 a 23:31


No, yo no hara eso, pero una pequea tapa de cermica de esa manera lo ms cerca posible a VCC (y
otra pierna a GND) podra ser una buena idea.

El vdeo es slo purga luz, la cmara no captura bien. Se parece mucho mejor en persona.

LED 8x8x8 Cubo - Parte 3, CDIGO


Si ya has hecho un montn de cdigo para el Arduino, en C, o cualquier otro idioma para ser honesto,
usted debe ser aceptable para escribir algunos diseos a la moda para el cubo. Tambin hay algunos
diseos a la moda ya est ah!Los mejores I ' he encontrado estn en esta pgina aqu , pero hay
muchos disponibles si usted busca alrededor. voy a asumir que usted sabe un poco acerca de la
codificacin, Si no lo hace, el sitio de aprendizaje Arduino debera ayudar a empezar. Usted al menos
desea que se haga tareas de los "bsico" en esa pgina, '' estructuras de control si no se sabe lo que
es un bucle for Strings 'y' si usted quiere hacer el texto. En primer lugar , vamos a ejecutar una
prueba. Una iluminacin LED en todas su cubo uno por uno para comprobar que todo el
trabajo! Haga clic aqu para ver el cdigo Usted puede poner ese cdigo en su recta Arduino. Si ha
conectado el cubo hasta el mismo que yo debera funcionar. Haz lo que quieras con ese cdigo, se
proporciona tal como es. Si desea escribir cdigo para probar el mismo LED, te recomiendo que
hagas! Se le dar una mejor comprensin de cmo funciona el cubo.Bsicamente, 'enciende' una
capa. A continuacin, establezca cada bit individual en una matriz de 8 bytes a 1, con todos los
dems 0. Luego cambie a cabo esos bytes a los registros (utilizando el mtodo lento, pero fcil,
'SHIFTOUT ()'). Contamos con 8 registros de desplazamiento, cada uno con 8 bits. Tambin tenemos
una serie de 8 bytes, cada uno con 8 bits! Qu hay de eso?!? Cuando hemos dado vuelta cada bit
en la matriz de encendido y apagado, de pasar a la siguiente capa. Cuando hemos hecho los 8
capas, empezamos de nuevo! Ahora, para los efectos propios LED Cube 3D tenemos que ser un
poco ms complicado y mucho ms rpido. Bsicamente, tenemos una matriz de 2 dimensiones de 8
bytes. Si sabes lo que eso significa, de lo que has aprendido lo suficiente como para ser capaz de
hacer esto! Cada byte puede hacer referencia a una columna, fila o 'columna vertical' en nuestro cubo
3D. Como ya saben: si un bit es 1, el LED est encendido, si es cero, el LED est apagado. Las
rutinas de efectos manipular esta matriz. Esas rutinas asumen lo que est en la matriz es lo que se
muestra en el cubo. A continuacin, utilizamos un temporizador digital, que es en nuestro Arduino (En
realidad, tiene unos pocos). Estos temporizadores se pueden configurar para causar lo que se
conoce como una "interrupcin '. Una interrupcin se ejecutar un poco de cdigo, en nuestro caso,
el bit de cdigo para mostrar lo que est en la matriz en el cubo. Si hacemos esta interrupcin sucede
con bastante frecuencia, y hacer que el trozo de cdigo que se ejecuta lo suficientemente rpido para
que los de Arduino procesador no siempre se ejecuta la interrupcin, tenemos cubo capaz de algunos
patrones sorprendentes! Hay algunas bibliotecas que vamos a tener que utilizar. En primer lugar una
biblioteca temporizador, para la funcin he hablado en el ltimo prrafo. Adems, utilizamos algo que
se llama SPI para transferir los datos, sus similares a SHIFTOUT pero mucho ms rpido. Aqu hay
un cdigo de trabajo Esto no es un gran cdigo, Su desordenado y todos ponen en un archivo para
que sea ms fcil de cargar. Estaba tan excitado por mi Cubo LED no poda programar con
sensatez! Aqu estn los enlaces a la biblioteca: http://arduino.cc/playground/Code/Timer1Incluye una
tabla ASCII completo para la visualizacin de texto y todos los efectos como se muestra en la
leyenda inscrutables 'CHR'. incluye algunas funciones interesantes como setvoxel () Fill (), los cuales
estn muy bien comentados en el cdigo. por cierto, un voxel es slo un pxel con coordenadas
3D. As que tiene la toma de la diversin cdigo para su cubo!
Anexo

http://bildr.org/2011/02/74hc595/

Se puede mover de nuevo? El


registro de desplazamiento
74HC595 8 bits TH
Cerrado martes, 8 de febrero de 2011

OK, as que usted tiene esta idea fresco loco donde tienes que controlar una tonelada de LED s (lo s,
lo s ... LEDs). Te veas en el artculo multiplexor , y que era genial, pero esta idea es tan fresco,
que necesita un control individual de cada LED, y convertirlos en uno a la vez simplemente no es
suficiente. Bien de nuevo, estamos aqu para ayudar, y ahora es el momento de presentarle el registro
de desplazamiento . No cualquier registro de desplazamiento , el super barato, muy
impresionante 74HC595 Shift 8-bit de registro!

Qu hace un registro de desplazamiento?


Bsicamente, un registro de desplazamiento, al final, le permiten ampliar en los digitales salidas que
tiene en su microcontroller . Cada uno de estos 74HC595s puede actuar como 8 ms salidas
digitales, y se puede conectar en cadena de ellos. Por lo que podra enganchar 8 de ellos al lado de la
otra y tener el control de 64 salidas.
Pero la forma en que funciona es un poco confuso para pensar en un primer momento, y estos son lo
suficientemente til que es realmente vale la pena entender qu diablos est pasando bajo el cap.
Se puede imaginar un registro de desplazamiento como una fila de sillas. En este caso en particular,
con el 74HC595 , tenemos una fila de 8 sillas. Cada silla est vaca (0), o alguien que est sentado (1).
Ahora, cada 10 segundos o as, alguien toca una campana, y cada uno tiene que levantarse y moverse
una silla a la derecha. Si haba alguien en esa silla ms a la derecha, y que, simplemente
desaparecen. En esa silla ms a la izquierda, puede decirle a alguien que se siente en ella, o
simplemente dejarlo vaco.
Ahora con lo que esta idea de nuevo a la 74HC595: Este registro de desplazamiento se compone de 8
pines de salida, que son bien alta (1) o bajo(0). Cuando tire del SRCLK (Reloj de serie)
pin alta (analoga con el toque de campana), cada pin mueve a la derecha. El ltimo pasador se retira,
y el estado del nuevo pasador se define por la SER ( Serial pines), y se puede establecer que a
cualquiera de 1 ( ALTO ) o 0 ( LOW ).
Cmo esto me permiti controlar LED s de nuevo? Bien, supongamos que tiene 8 LEDs conectados
al registro de desplazamiento salidas s, y nos quieren convertir en la 1, 3 y la 8 LED. As que ...
lo que podemos hacer es limpiar el registro de modo que todos los LEDs estn apagados. A
continuacin, ponemos en un alto, mueven a la derecha 4 puntos, agrega uno alto, moverlo ms de 1, a
continuacin, aadir otra alta. Ver la imagen de la derecha, que tendr ms sentido.
Lo bueno es que el registro de desplazamiento tiene este perno llamada RCLK o registrarse
reloj. Puede mantener esta baja alfiler, mientras que se obtiene la configuracin de todo y nada en los
pines de visualizacin cambiar. Luego, cuando haya terminado, y todo es cmo desea, se tire de la
RCLK HIGH y el 74HC595 se mostrar la nueva configuracin. As que a pesar de que estamos
cambiando los valores en el registro en 8 pasos, parece que fue slo un paso.

Conectarlo
Vamos a empezar de forma sencilla. En realidad, hay slo 3 conexiones que necesita, aparte de poder
para hacer este trabajo. Pero tan pronto como el poder y los LED estn todos conectados, se pone a
buscar miedo. Pero no lo es, lo que se adhieren con nosotros. - Se puede ver una hoja de
especificaciones para el 74HC595 aqu .
Vcc
hasta 6V (tiene que ser el mismo voltaje que el microcontrolador) - Por lo general 3,3 / 5v
Control de calidad para QH
Registro de desplazamiento salidas.
SER :
(de serie) de entrada para el siguiente pin que consigue movi en.
SRCLK
(Reloj de serie) Cuando este pin se tira alto, se desplazar el registro.
RCLK
(Registro del reloj) necesita ser tirada alta para ajustar la salida a los nuevos valores de registro de desplazamiento, este
debe ser retirado de alta directamente despus SRCLK ha ido BAJA nuevo.
SRCLR
(Claro de serie) se vaciar todo el registro de desplazamiento si bien calado, se debe tirar de alta habilitar.
OE
(habilitacin de salida) Este pasador permite la salida cuando atado a GND, y si est desactivada ALTO.

Cmo lo hacemos funcionar


Siempre que la seal en el SERCLK pines pasa a nivel alto, todos los valores quedan desplazan a la
derecha, y un nuevo valor se desplaza un en (Cualquiera que sea la SER est en). Despus de que se
removi en su nuevo valor, para ver los cambios realizados, tambin debe establecer el pin a nivel alto
RCLK con el fin de actualizar las salidas-pins con los nuevos datos. Quisimos obtener su de
funcionamiento lo ms rpido posible, por lo que tuvimos que crear algo de cdigo para el Arduino ,
y AVR microcontroladores : ver ms abajo para ejemplos de cdigo.
El ejemplo Arduino permite el control individual de los pasadores de registro. Sin embargo, el ejemplo
AVR no lo hace actualmente y debe ser alimentado con una secuencia binaria. Si usted est interesado
en ayudar a transcodificar el cdigo de Arduino en AVR (o cualquier otro idioma) por lo que va a
apoyar peticiones de control pines individuales, hganoslo saber.
cdigo de la copia

setRegisterPin ( 2 , HIGH ) ;
setRegisterPin ( 3 , HIGH ) ;
setRegisterPin ( 4 , LOW ) ;
setRegisterPin ( 5 , HIGH ) ;
setRegisterPin ( 7 , HIGH ) ;

// Una vez que haya establecido los cambios deseados en los


pasadores // registrar, tendr que llamar writeRegisters
// antes de ser mostrada. Slo haga esto, al final,
// y no despus de cada llamada setRegisterPin ya que esta
funcin // toma un tiempo para escribir los valores.
// WriteRegisters tarda alrededor de 1 ms por cada 10 de
// los registros de desplazamiento que ha encadenado (80 pins)
writeRegisters ( ) ;
A menos que se indique lo contrario, este cdigo se distribuye bajo la licencia MIT - Por favor, use, el cambio y compartirlo.

En cascada Shift Register - Tambin conocido como encadenndolos


Como he dicho anteriormente, se podra conectar 20 de ellos juntos si se necesitaba. registros de
desplazamiento tienen una opcin muy inteligente integrado que les permite ser encadenados o juntos
en cascada. Usted sabe cmo el ltimo registro simplemente vuelca su valor cuando se desplaza de
nuevo?Bueno, el pasador Qc (pin 9) es donde el 74HC595 vertederos de ese valor. As que nosotros
slo eso y lo usamos como la entrada de la SER en una segunda (o siguiente) registro de
desplazamiento, y bam! estn encadenados juntos.Tambin tendr que luego conectar los pines
SERCLK y RCLK juntos, pero entonces usted es de oro. Echa un vistazo a los esquemas a un lado y
abajo para ver cmo est conectado.
Cdigo
cdigo de Arduino para el control individual sobre cada pin - Soporte para
ms de 40 registros de desplazamiento
cdigo de la copia
int SER_Pin = 8 ; // pin 14 en el 75HC595
int RCLK_Pin = 9 ; // pasador 12 en el 75HC595
int SRCLK_Pin = 10 ; // pin 11 en el 75HC595

// Cuntos de los registros de desplazamiento - cambiar esta


#define number_of_74hc595s 1

// no toque
numOfRegisterPins number_of_74hc595s #define * 8

booleanas registros [ numOfRegisterPins ] ;


void setup ( ) {
pinMode ( SER_Pin , SALIDA ) ;
pinMode ( RCLK_Pin , SALIDA ) ;
pinMode ( SRCLK_Pin , SALIDA ) ;

// restablecer todos los pasadores de registro


clearRegisters ( ) ;
writeRegisters ( ) ;
}

// establecer todos los pines de registro a menor


vaco clearRegisters ( ) {
a ( int i = numOfRegisterPins - 1 ; i > = 0 ; i - ) {
registros [ i ] = BAJO ;
}
}

// Ajustar y visualizar registros


// Slo llamada despus de todos los valores se establecen la forma en que le
gustara (lento de lo contrario)
void writeRegisters ( ) {

digitalWrite ( RCLK_Pin , LOW ) ;

para ( int i = numOfRegisterPins - 1 ; i > = 0 ; i - ) {


digitalWrite ( SRCLK_Pin , LOW ) ;

int val = registros [ i ] ;

digitalWrite ( SER_Pin , val ) ;


digitalWrite ( SRCLK_Pin , ALTA ) ;

}
DigitalWrite ( RCLK_Pin , ALTA ) ;

// establecer un PIN individual ALTO o BAJO


vaco setRegisterPin ( int index , int valor ) {
registros [ ndice ] = valor ;
}

void loop ( ) {
setRegisterPin ( 2 , HIGH ) ;
setRegisterPin ( 3 , HIGH ) ;
setRegisterPin ( 4 , LOW ) ;
setRegisterPin ( 5 , HIGH ) ;
setRegisterPin ( 7 , HIGH ) ;

writeRegisters ( ) ; // debe ser llamada para mostrar los cambios


// llamada de slo una vez despus de que los valores se establecen la forma
en que necesita.
}

A menos que se indique lo contrario, este cdigo se distribuye bajo la licencia MIT - Por favor, use, el
cambio y compartirlo.

Este ejemplo de cdigo simplemente se enciende los LED en un patrn particular y lo mantiene
aqu. (Este cdigo slo se admite hasta 4 registros de desplazamiento. Debido a que tomar en un
nmero binario, que se limita a 32 caracteres.)
Aqu est el cdigo para el AVR

cdigo de la copia
#include <avr / io.h>
#include <util / delay.h>

number_of_74hc595s #define 1 // Cuntos de los registros de desplazamiento


estn ah daisey encadenado?

int principal ( ) {
DDRB = 0xFF ;
PORTB = 0x00 ;
Char contador = 0 ;

mientras que ( 1 ) {
contador ++; // contador utilizado
para la visualizacin de un nmero en binario a travs del registro de
desplazamiento de
desplazamiento ( PB1 , PB2 , PB3 , contador ) ; //
= PB1 PB2 = SERCLK RCLK PB3 = SER
_delay_ms ( 500 ) ;
turno ( PB1 , PB2 , PB3 , 0x00 ) ; // Establecer
todos los pines a fuera
_delay_ms ( 500 ) ;
}
retorno 0 ;
}

sin efecto desplazamiento ( int SRCLK_Pin , int RCLK_Pin , int SER_Pin , sin
firmar larga de datos ) {
PORTB & = ~ ( 1 << RCLK_Pin ) ; //
Establecer el pasador de registro-reloj de baja

para ( int i = 0 ; i < ( 8 * number_of_74hc595s ) ; i ++ ) { //


Ahora estamos entrando en el bucle para cambiar de puesto 8+ los bits

PORTB & = ~ ( 1 << SRCLK_Pin ) ; //


Establecer el pasador de serie-reloj de baja

PORTB | = ( ( ( datos y ( 0x01 << i ) ) >> i ) << SER_Pin ) ;


// Ir a travs de cada bit de datos y la salida se

PORTB | = ( 1 << SRCLK_Pin ) ; //


Establecer el pasador de serie-reloj de alta

PORTB & = ~ ( ( ( datos y ( 0x01 << i ) ) >> i ) << SER_Pin )


; // Establecer la baja DataPin nuevo
}

PORTB | = ( 1 << RCLK_Pin ) ; //


Establecer el pasador de registro-reloj de alta para actualizar la salida del
registro de desplazamiento
}

A menos que se indique lo contrario, este cdigo se distribuye bajo la licencia MIT - Por favor, use, el
cambio y compartirlo.

Conclusin
Si necesita una manera fcil de extender sus salidas-pins, registros de desplazamiento son sin duda
una buena eleccin. Son baratos, rpido y si se toma el tiempo para jugar con ellos, que son bastante
simple tambin.

SHARE

TWEET

8x8x8 LED cube Test http://pastebin.com/cPMpj78A


JACKSONLIAM MAR 16TH, 2012 4,670 NEVER
rawdownloadcloneembedreportprintC 1.21 KB

1. //Test an 8x8x8 LED cube

2.

3.

4. //--- Pin connected to ST_CP of 74HC595

5. int latchPin = 10;

6. //--- Pin connected to SH_CP of 74HC595

7. int clockPin = 13;

8. //--- Pin connected to DS of 74HC595

9. int dataPin = 11;

10.

11. byte pinVals[8];

12. int zLayer = 0;

13. int xc = 0;

14. int yc = 0;

15.

16. void setup(){

17. //layer pins

18. for(int i = 2; i < 10; i++)

19. {

20. pinMode(i, OUTPUT);

21. digitalWrite(i, LOW);

22. }

23.

24. pinMode(latchPin, OUTPUT);

25. pinMode(clockPin, OUTPUT);

26. pinMode(dataPin, OUTPUT);

27.

28. digitalWrite(latchPin,LOW);
29. digitalWrite(dataPin,LOW);

30. digitalWrite(clockPin,LOW);

31.

32. bitSet(pinVals[0], 0);

33. digitalWrite(zLayer + 2, HIGH);

34. }

35.

36. void loop(){

37. digitalWrite(latchPin, LOW);


38. for(int i = 0; i < 8; i++){

39. shiftOut(dataPin, clockPin, MSBFIRST, pinVals[i]);

40. }

41. digitalWrite(latchPin, HIGH);


42.

43. //Increase for slower effect

44. delay(50);

45.

46. //Set the display bits

47. bitClear(pinVals[yc], xc);

48. xc++;

49. if(xc == 8){

50. xc = 0;

51. yc++;

52. if(yc == 8){

53. yc = 0;

54. //next z layer

55. digitalWrite(zLayer + 2, LOW);

56. zLayer++;

57. if(zLayer >= 8){

58. zLayer = 0;

59. }

60. digitalWrite(zLayer + 2, HIGH);

61. }

62. }

63. bitSet(pinVals[yc], xc);


64. }

RAW Paste Data

//Test an 8x8x8 LED cube

//--- Pin connected to ST_CP of 74HC595

int latchPin = 10;

//--- Pin connected to SH_CP of 74HC595

int clockPin = 13;

//--- Pin connected to DS of 74HC595

int dataPin = 11;


byte pinVals[8];

int zLayer = 0;

int xc = 0;

int yc = 0;

void setup(){

//layer pins

for(int i = 2; i < 10; i++)

pinMode(i, OUTPUT);

digitalWrite(i, LOW);

pinMode(latchPin, OUTPUT);

pinMode(clockPin, OUTPUT);

pinMode(dataPin, OUTPUT);

digitalWrite(latchPin,LOW);

digitalWrite(dataPin,LOW);

digitalWrite(clockPin,LOW);

bitSet(pinVals[0], 0);
digitalWrite(zLayer + 2, HIGH);

void loop(){

digitalWrite(latchPin, LOW);

for(int i = 0; i < 8; i++){

shiftOut(dataPin, clockPin, MSBFIRST, pinVals[i]);

digitalWrite(latchPin, HIGH);

//Increase for slower effect

delay(50);

//Set the display bits

bitClear(pinVals[yc], xc);

xc++;

if(xc == 8){

xc = 0;

yc++;

if(yc == 8){

yc = 0;

//next z layer

digitalWrite(zLayer + 2, LOW);
zLayer++;

if(zLayer >= 8){

zLayer = 0;

digitalWrite(zLayer + 2, HIGH);

bitSet(pinVals[yc], xc);

SHARE

TWEET

8x8x8 LED Cube Patterns Arduino


JACKSONLIAM MAR 16TH, 2012 7,710 NEVER

rawdownloadcloneembedreportprintC 47.20 KB

C 47.20 KB

1. /***************************************************************************************

2. * Name : LED CUBE 8x8x8 74HC595

3. * By : Liam Jackson

4.

5. Based on code by Joseph Francis (74hc595 SPI)

6. and by chr at instructables

7. http://www.instructables.com/id/Led-Cube-8x8x8/step70/Run-the-cube-on-an-Arduino/

8. Font found somewhere

9. ****************************************************************************************/

10.

11. #include <TimerOne.h>


12. #include <string.h>

13. #define AXIS_X 1

14. #define AXIS_Y 2

15. #define AXIS_Z 3


16.

17. //--- Pin connected to ST_CP of 74HC595

18. int latchPin = 10;

19. //--- Pin connected to SH_CP of 74HC595

20. int clockPin = 13;

21. //--- Pin connected to DS of 74HC595

22. int dataPin = 11;

23. //--- Used for faster latching

24. int latchPinPORTB = latchPin - 8;

25. //holds value for all the pins, [x][y][z]

26. byte cube[8][8];

27.

28. //Counts through the layers

29. int current_layer = 0;

30.

31. //--- This process is run by the timer and does the PWM control

32. void iProcess(){

33. //last layer store

34. int oldLayerBit = current_layer + 2;

35.

36. //increment layer count

37. current_layer++;

38. if(current_layer >= 8){

39. current_layer = 0;

40. }

41.

42. //--- Run through all the shift register values and send them (last one first)

43. // latching in the process

44. latchOff();
45. for (int i = 0 ; i < 8 ; i++){

46. spi_transfer(cube[current_layer][i]);

47. }

48.

49. //Hide the old layer

50. digitalWrite(oldLayerBit, LOW);

51. //New data on the pins

52. latchOn();

53. //new layer high


54. digitalWrite(current_layer + 2, HIGH);

55. }

56.

57. //--- Direct port access latching


58. void latchOn(){

59. bitSet(PORTB,latchPinPORTB);

60. }

61. void latchOff(){

62. bitClear(PORTB,latchPinPORTB);

63. }

64.

65. //--- Used to setup SPI based on current pin setup

66. // this is called in the setup routine;

67. void setupSPI(){

68. byte clr;

69. SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master

70. SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits

71. clr=SPSR; // clear SPI status reg

72. clr=SPDR; // clear SPI data reg

73. SPSR |= (1<<SPI2X); // set prescaler bits

74. delay(10);

75. }

76.

77. //--- The really fast SPI version of shiftOut

78. byte spi_transfer(byte data)

79. {

80. SPDR = data; // Start the transmission

81. loop_until_bit_is_set(SPSR, SPIF);

82. return SPDR; // return the received byte, we don't need that

83. }

84.

85. void setup() {

86. Serial.begin(9600);
87.

88. //layer pins

89. for(int i = 2; i < 10; i++)

90. {

91. pinMode(i, OUTPUT);

92. }

93.

94. pinMode(latchPin, OUTPUT);

95. pinMode(clockPin, OUTPUT);


96. pinMode(dataPin, OUTPUT);

97.

98. digitalWrite(latchPin,LOW);

99. digitalWrite(dataPin,LOW);
100. digitalWrite(clockPin,LOW);

101.

102. //--- Setup to run SPI

103. setupSPI();

104.

105. //--- Activate the PWM timer

106. Timer1.initialize(100); // Timer for updating pwm pins

107. Timer1.attachInterrupt(iProcess);

108. }

109.

110.

111. void loop(){

112. int i,x,y,z;

113.

114. while (true)

115. {

116. effect_text(800);

117.

118. effect_box_wamp(1000);

119.

120. effect_rain(100);

121.

122. effect_planboing(AXIS_Z, 400);

123. effect_planboing(AXIS_Y, 400);

124. effect_planboing(AXIS_X, 400);

125.

126. effect_blinky2();

127.

128. effect_random_filler(75,1);
129. effect_random_filler(75,0);

130.

131. effect_boxside_randsend_parallel (AXIS_X, 0, 150, 1);

132. effect_boxside_randsend_parallel (AXIS_X, 1, 150, 1);

133. effect_boxside_randsend_parallel (AXIS_Y, 0, 150, 1);

134. effect_boxside_randsend_parallel (AXIS_Y, 1, 150, 1);

135. effect_boxside_randsend_parallel (AXIS_Z, 0, 150, 1);

136. effect_boxside_randsend_parallel (AXIS_Z, 1, 150, 1);

137.
138. }

139. }

140.
141. //

==========================================================================================

142. // TEXT Functions

143. //

==========================================================================================

144. char font_data[128][8] = {

145. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0 :

146. // | |

147. // | |

148. // | |

149. // | |

150. // | |

151. // | |

152. // | |

153. // | |

154.

155. { 0x00, 0x3E, 0x41, 0x55, 0x41, 0x55, 0x49, 0x3E }, // 1 :

156. // | |

157. // | ***** |

158. // | * * |

159. // | * * * * |

160. // | * * |

161. // | * * * * |

162. // | * * * |

163. // | ***** |

164.

165. { 0x00, 0x3E, 0x7F, 0x6B, 0x7F, 0x6B, 0x77, 0x3E }, // 2 :

166. // | |

167. // | ***** |
168. // | ******* |

169. // | ** * ** |

170. // | ******* |

171. // | ** * ** |

172. // | *** *** |

173. // | ***** |

174.

175. { 0x00, 0x22, 0x77, 0x7F, 0x7F, 0x3E, 0x1C, 0x08 }, // 3 :

176. // | |

177. // | * * |

178. // | *** *** |

179. // | ******* |
180. // | ******* |

181. // | ***** |

182. // | *** |

183. // | * |

184.

185. { 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08 }, // 4 :

186. // | |

187. // | * |

188. // | *** |

189. // | ***** |

190. // | ******* |

191. // | ***** |

192. // | *** |

193. // | * |

194.

195. { 0x00, 0x08, 0x1C, 0x2A, 0x7F, 0x2A, 0x08, 0x1C }, // 5 :

196. // | |

197. // | * |

198. // | *** |

199. // | * * * |

200. // | ******* |

201. // | * * * |

202. // | * |

203. // | *** |

204.

205. { 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x08, 0x1C }, // 6 :

206. // | |

207. // | * |
208. // | *** |

209. // | ***** |

210. // | ******* |

211. // | ***** |

212. // | * |

213. // | *** |

214.

215. { 0x00, 0x00, 0x1C, 0x3E, 0x3E, 0x3E, 0x1C, 0x00 }, // 7 :

216. // | |
217. // | |

218. // | *** |

219. // | ***** |

220. // | ***** |
221. // | ***** |

222. // | *** |

223. // | |

224.

225. { 0xFF, 0xFF, 0xE3, 0xC1, 0xC1, 0xC1, 0xE3, 0xFF }, // 8 :

226. // | ******** |

227. // | ******** |

228. // | *** ** |

229. // | ** * |

230. // | ** * |

231. // | ** * |

232. // | *** ** |

233. // | ******** |

234.

235. { 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00 }, // 9 :

236. // | |

237. // | |

238. // | *** |

239. // | * * |

240. // | * * |

241. // | * * |

242. // | *** |

243. // | |

244.

245. { 0xFF, 0xFF, 0xE3, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF }, // 10 :

246.

247. // | ******** |

248. // | ******** |

249. // | *** ** |
250. // | ** *** * |

251. // | ** *** * |

252. // | ** *** * |

253. // | *** ** |

254. // | ******** |

255.

256. { 0x00, 0x0F, 0x03, 0x05, 0x39, 0x48, 0x48, 0x30 }, // 11 :

257. // | |

258. // | **** |
259. // | ** |

260. // | * * |

261. // | *** * |

262. // | * * |
263. // | * * |

264. // | ** |

265.

266. { 0x00, 0x08, 0x3E, 0x08, 0x1C, 0x22, 0x22, 0x1C }, // 12 :


267. // | |

268. // | * |

269. // | ***** |

270. // | * |

271. // | *** |

272. // | * * |

273. // | * * |

274. // | *** |

275.

276. { 0x00, 0x18, 0x14, 0x10, 0x10, 0x30, 0x70, 0x60 }, // 13 :

277.

278. // | |

279. // | ** |

280. // | * * |

281. // | * |

282. // | * |

283. // | ** |

284. // | *** |

285. // | ** |

286.

287. { 0x00, 0x0F, 0x19, 0x11, 0x13, 0x37, 0x76, 0x60 }, // 14 :


288. // | |

289. // | **** |

290. // | ** * |

291. // | * * |

292. // | * ** |

293. // | ** *** |

294. // | *** ** |

295. // | ** |

296.

297. { 0x00, 0x08, 0x2A, 0x1C, 0x77, 0x1C, 0x2A, 0x08 }, // 15 :

298. // | |

299. // | * |

300. // | * * * |

301. // | *** |

302. // | *** *** |

303. // | *** |

304. // | * * * |

305. // | * |

306.

307. { 0x00, 0x60, 0x78, 0x7E, 0x7F, 0x7E, 0x78, 0x60 }, // 16 :

308. // | |

309. // | ** |

310. // | **** |

311. // | ****** |

312. // | ******* |

313. // | ****** |

314. // | **** |

315. // | ** |
316.

317. { 0x00, 0x03, 0x0F, 0x3F, 0x7F, 0x3F, 0x0F, 0x03 }, // 17 :

318. // | |

319. // | ** |

320. // | **** |

321. // | ****** |

322. // | ******* |

323. // | ****** |

324. // | **** |
325. // | ** |

326.

327. { 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x08 }, // 18 :

328. // | |
329. // | * |

330. // | *** |

331. // | * * * |

332. // | * |

333. // | * * * |

334. // | *** |

335. // | * |

336.

337. { 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66 }, // 19 :

338. // | |

339. // | ** ** |

340. // | ** ** |

341. // | ** ** |

342. // | ** ** |

343. // | |

344. // | ** ** |

345. // | ** ** |

346.

347. { 0x00, 0x3F, 0x65, 0x65, 0x3D, 0x05, 0x05, 0x05 }, // 20 :

348. // | |

349. // | ****** |

350. // | ** * * |

351. // | ** * * |

352. // | **** * |

353. // | * * |

354. // | * * |

355. // | * * |

356.

357. { 0x00, 0x0C, 0x32, 0x48, 0x24, 0x12, 0x4C, 0x30 }, // 21 :


358. // | |

359. // | ** |

360. // | ** * |

361. // | * * |

362. // | * * |

363. // | * * |

364. // | * ** |

365. // | ** |

366.
367. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }, // 22 :

368. // | |

369. // | |

370. // | |
371. // | |

372. // | |

373. // | ******* |

374. // | ******* |

375. // | ******* |

376.

377. { 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x3E }, // 23 :

378. // | |

379. // | * |

380. // | *** |

381. // | * * * |

382. // | * |

383. // | * * * |

384. // | *** |

385. // | ***** |

386.

387. { 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x1C, 0x1C, 0x1C }, // 24 :

388. // | |

389. // | * |

390. // | *** |

391. // | ***** |

392. // | ******* |

393. // | *** |

394. // | *** |

395. // | *** |

396.

397. { 0x00, 0x1C, 0x1C, 0x1C, 0x7F, 0x3E, 0x1C, 0x08 }, // 25 :

398. // | |

399. // | *** |
400. // | *** |

401. // | *** |

402. // | ******* |

403. // | ***** |

404. // | *** |

405. // | * |

406.

407. { 0x00, 0x08, 0x0C, 0x7E, 0x7F, 0x7E, 0x0C, 0x08 }, // 26 :

408. // | |
409. // | * |

410. // | ** |

411. // | ****** |

412. // | ******* |
413. // | ****** |

414. // | ** |

415. // | * |

416.

417. { 0x00, 0x08, 0x18, 0x3F, 0x7F, 0x3F, 0x18, 0x08 }, // 27 :

418. // | |

419. // | * |

420. // | ** |

421. // | ****** |

422. // | ******* |

423. // | ****** |

424. // | ** |

425. // | * |

426.

427. { 0x00, 0x00, 0x00, 0x70, 0x70, 0x70, 0x7F, 0x7F }, // 28 :

428. // | |

429. // | |

430. // | |

431. // | *** |

432. // | *** |

433. // | *** |

434. // | ******* |

435. // | ******* |

436.

437. { 0x00, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00 }, // 29 :

438. // | |

439. // | |

440. // | * * |

441. // | * * |
442. // | ******* |

443. // | * * |

444. // | * * |

445. // | |

446.

447. { 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x3E, 0x7F, 0x7F }, // 30 : -

448. // | |

449. // | * |

450. // | *** |
451. // | *** |

452. // | ***** |

453. // | ***** |

454. // | ******* |
455. // | ******* |

456.

457. { 0x00, 0x7F, 0x7F, 0x3E, 0x3E, 0x1C, 0x1C, 0x08 }, // 31 :

458. // | |

459. // | ******* |

460. // | ******* |

461. // | ***** |

462. // | ***** |

463. // | *** |

464. // | *** |

465. // | * |

466.

467. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32 :

468. // | |

469. // | |

470. // | |

471. // | |

472. // | |

473. // | |

474. // | |

475. // | |

476.

477. { 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18 }, // 33 : !

478. // | |

479. // | ** |

480. // | ** |

481. // | ** |

482. // | ** |

483. // | ** |
484. // | |

485. // | ** |

486.

487. { 0x00, 0x36, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00 }, // 34 : "

488. // | |

489. // | ** ** |

490. // | ** ** |

491. // | * * |

492. // | |
493. // | |

494. // | |

495. // | |

496.
497. { 0x00, 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36 }, // 35 : #

498. // | |

499. // | ** ** |

500. // | ** ** |

501. // | ******* |

502. // | ** ** |

503. // | ******* |

504. // | ** ** |

505. // | ** ** |

506.

507. { 0x00, 0x08, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x08 }, // 36 : $

508. // | |

509. // | * |

510. // | **** |

511. // | * |

512. // | *** |

513. // | * |

514. // | **** |

515. // | * |

516.

517. { 0x00, 0x60, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x06 }, // 37 : %

518. // | |

519. // | ** |

520. // | ** ** |

521. // | ** |

522. // | ** |

523. // | ** |

524. // | ** ** |

525. // | ** |
526.

527. { 0x00, 0x3C, 0x66, 0x3C, 0x28, 0x65, 0x66, 0x3F }, // 38 : &

528. // | |

529. // | **** |

530. // | ** ** |

531. // | **** |

532. // | * * |

533. // | ** * * |

534. // | ** ** |
535. // | ****** |

536.

537. { 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00 }, // 39 : '

538. // | |
539. // | ** |

540. // | ** |

541. // | ** |

542. // | ** |

543. // | |

544. // | |

545. // | |

546.

547. { 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60 }, // 40 : (

548. // | |

549. // | ** |

550. // | ** |

551. // | ** |

552. // | ** |

553. // | ** |

554. // | ** |

555. // | ** |

556.

557. { 0x00, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06 }, // 41 : )

558. // | |

559. // | ** |

560. // | ** |

561. // | ** |

562. // | ** |

563. // | ** |

564. // | ** |

565. // | ** |

566.

567. { 0x00, 0x00, 0x36, 0x1C, 0x7F, 0x1C, 0x36, 0x00 }, // 42 : *


568. // | |

569. // | |

570. // | ** ** |

571. // | *** |

572. // | ******* |

573. // | *** |

574. // | ** ** |

575. // | |

576.
577. { 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00 }, // 43 : +

578. // | |

579. // | |

580. // | * |
581. // | * |

582. // | ***** |

583. // | * |

584. // | * |

585. // | |

586.

587. { 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60 }, // 44 : ,

588. // | |

589. // | |

590. // | |

591. // | |

592. // | ** |

593. // | ** |

594. // | ** |

595. // | ** |

596.

597. { 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00 }, // 45 : -

598. // | |

599. // | |

600. // | |

601. // | |

602. // | **** |

603. // | |

604. // | |

605. // | |

606.

607. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60 }, // 46 : .

608. // | |

609. // | |
610. // | |

611. // | |

612. // | |

613. // | |

614. // | ** |

615. // | ** |

616.

617. { 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00 }, // 47 : /

618. // | |
619. // | |

620. // | ** |

621. // | ** |

622. // | ** |
623. // | ** |

624. // | ** |

625. // | |

626.

627. { 0x00, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C }, // 48 : 0

628. // | |

629. // | **** |

630. // | ** ** |

631. // | ** *** |

632. // | *** ** |

633. // | ** ** |

634. // | ** ** |

635. // | **** |

636.

637. { 0x00, 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x7E }, // 49 : 1

638. // | |

639. // | ** |

640. // | ** |

641. // | *** |

642. // | ** |

643. // | ** |

644. // | ** |

645. // | ****** |

646.

647. { 0x00, 0x3C, 0x66, 0x06, 0x0C, 0x30, 0x60, 0x7E }, // 50 : 2

648. // | |

649. // | **** |

650. // | ** ** |

651. // | ** |
652. // | ** |

653. // | ** |

654. // | ** |

655. // | ****** |

656.

657. { 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C }, // 51 : 3

658. // | |

659. // | **** |

660. // | ** ** |
661. // | ** |

662. // | *** |

663. // | ** |

664. // | ** ** |
665. // | **** |

666.

667. { 0x00, 0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C }, // 52 : 4

668. // | |

669. // | ** |

670. // | *** |

671. // | * ** |

672. // | * ** |

673. // | ****** |

674. // | ** |

675. // | ** |

676.

677. { 0x00, 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C }, // 53 : 5

678. // | |

679. // | ****** |

680. // | ** |

681. // | ***** |

682. // | ** |

683. // | ** |

684. // | ** ** |

685. // | **** |

686.

687. { 0x00, 0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C }, // 54 : 6

688. // | |

689. // | **** |

690. // | ** ** |

691. // | ** |

692. // | ***** |

693. // | ** ** |
694. // | ** ** |

695. // | **** |

696.

697. { 0x00, 0x7E, 0x66, 0x0C, 0x0C, 0x18, 0x18, 0x18 }, // 55 : 7

698. // | |

699. // | ****** |

700. // | ** ** |

701. // | ** |

702. // | ** |
703. // | ** |

704. // | ** |

705. // | ** |

706.
707. { 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C }, // 56 : 8

708. // | |

709. // | **** |

710. // | ** ** |

711. // | ** ** |

712. // | **** |

713. // | ** ** |

714. // | ** ** |

715. // | **** |

716.

717. { 0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C }, // 57 : 9

718. // | |

719. // | **** |

720. // | ** ** |

721. // | ** ** |

722. // | ***** |

723. // | ** |

724. // | ** ** |

725. // | **** |

726.

727. { 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00 }, // 58 : :

728. // | |

729. // | |

730. // | ** |

731. // | ** |

732. // | |

733. // | ** |

734. // | ** |

735. // | |
736.

737. { 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30 }, // 59 : ;

738. // | |

739. // | |

740. // | ** |

741. // | ** |

742. // | |

743. // | ** |

744. // | ** |
745. // | ** |

746.

747. { 0x00, 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06 }, // 60 : <

748. // | |
749. // | ** |

750. // | ** |

751. // | ** |

752. // | ** |

753. // | ** |

754. // | ** |

755. // | ** |

756.

757. { 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00 }, // 61 : =

758. // | |

759. // | |

760. // | |

761. // | **** |

762. // | |

763. // | **** |

764. // | |

765. // | |

766.

767. { 0x00, 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60 }, // 62 : >

768. // | |

769. // | ** |

770. // | ** |

771. // | ** |

772. // | ** |

773. // | ** |

774. // | ** |

775. // | ** |

776.

777. { 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18 }, // 63 : ?


778. // | |

779. // | **** |

780. // | ** ** |

781. // | ** |

782. // | *** |

783. // | ** |

784. // | |

785. // | ** |

786.
787. { 0x00, 0x38, 0x44, 0x5C, 0x58, 0x42, 0x3C, 0x00 }, // 64 : @

788. // | |

789. // | *** |

790. // | * * |
791. // | * *** |

792. // | * ** |

793. // | * * |

794. // | **** |

795. // | |

796.

797. { 0x00, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66 }, // 65 : A

798. // | |

799. // | **** |

800. // | ** ** |

801. // | ** ** |

802. // | ****** |

803. // | ** ** |

804. // | ** ** |

805. // | ** ** |

806.

807. { 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C }, // 66 : B

808. // | |

809. // | ***** |

810. // | ** ** |

811. // | ** ** |

812. // | ***** |

813. // | ** ** |

814. // | ** ** |

815. // | ***** |

816.

817. { 0x00, 0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C }, // 67 : C

818. // | |

819. // | **** |
820. // | ** ** |

821. // | ** |

822. // | ** |

823. // | ** |

824. // | ** ** |

825. // | **** |

826.

827. { 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C }, // 68 : D

828. // | |
829. // | ***** |

830. // | ** ** |

831. // | ** ** |

832. // | ** ** |
833. // | ** ** |

834. // | ** ** |

835. // | ***** |

836.

837. { 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x7E }, // 69 : E

838. // | |

839. // | ****** |

840. // | ** |

841. // | ** |

842. // | ***** |

843. // | ** |

844. // | ** |

845. // | ****** |

846.

847. { 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60 }, // 70 : F

848. // | |

849. // | ****** |

850. // | ** |

851. // | ** |

852. // | ***** |

853. // | ** |

854. // | ** |

855. // | ** |

856.

857. { 0x00, 0x3C, 0x66, 0x60, 0x60, 0x6E, 0x66, 0x3C }, // 71 : G

858. // | |

859. // | **** |

860. // | ** ** |

861. // | ** |
862. // | ** |

863. // | ** *** |

864. // | ** ** |

865. // | **** |

866.

867. { 0x00, 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66 }, // 72 : H

868. // | |

869. // | ** ** |

870. // | ** ** |
871. // | ** ** |

872. // | ****** |

873. // | ** ** |

874. // | ** ** |
875. // | ** ** |

876.

877. { 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C }, // 73 : I

878. // | |

879. // | **** |

880. // | ** |

881. // | ** |

882. // | ** |

883. // | ** |

884. // | ** |

885. // | **** |

886.

887. { 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x6C, 0x6C, 0x38 }, // 74 : J

888. // | |

889. // | **** |

890. // | ** |

891. // | ** |

892. // | ** |

893. // | ** ** |

894. // | ** ** |

895. // | *** |

896.

897. { 0x00, 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66 }, // 75 : K

898. // | |

899. // | ** ** |

900. // | ** ** |

901. // | **** |

902. // | *** |

903. // | **** |
904. // | ** ** |

905. // | ** ** |

906.

907. { 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E }, // 76 : L

908. // | |

909. // | ** |

910. // | ** |

911. // | ** |

912. // | ** |
913. // | ** |

914. // | ** |

915. // | ****** |

916.
917. { 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63 }, // 77 : M

918. // | |

919. // | ** ** |

920. // | *** *** |

921. // | ******* |

922. // | ** * ** |

923. // | ** ** |

924. // | ** ** |

925. // | ** ** |

926.

927. { 0x00, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x63, 0x63 }, // 78 : N

928. // | |

929. // | ** ** |

930. // | *** ** |

931. // | **** ** |

932. // | ** **** |

933. // | ** *** |

934. // | ** ** |

935. // | ** ** |

936.

937. { 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C }, // 79 : O

938. // | |

939. // | **** |

940. // | ** ** |

941. // | ** ** |

942. // | ** ** |

943. // | ** ** |

944. // | ** ** |

945. // | **** |
946.

947. { 0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60 }, // 80 : P

948. // | |

949. // | ***** |

950. // | ** ** |

951. // | ** ** |

952. // | ** ** |

953. // | ***** |

954. // | ** |
955. // | ** |

956.

957. { 0x00, 0x3C, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x06 }, // 81 : Q

958. // | |
959. // | **** |

960. // | ** ** |

961. // | ** ** |

962. // | ** ** |

963. // | ** *** |

964. // | **** |

965. // | ** |

966.

967. { 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x78, 0x6C, 0x66 }, // 82 : R

968. // | |

969. // | ***** |

970. // | ** ** |

971. // | ** ** |

972. // | ***** |

973. // | **** |

974. // | ** ** |

975. // | ** ** |

976.

977. { 0x00, 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C }, // 83 : S

978. // | |

979. // | **** |

980. // | ** ** |

981. // | ** |

982. // | **** |

983. // | ** |

984. // | ** ** |

985. // | **** |

986.

987. { 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x18 }, // 84 : T


988. // | |

989. // | ****** |

990. // | * ** * |

991. // | ** |

992. // | ** |

993. // | ** |

994. // | ** |

995. // | ** |

996.
997. { 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E }, // 85 : U

998. // | |

999. // | ** ** |

1000. // | ** ** |
1001. // | ** ** |

1002. // | ** ** |

1003. // | ** ** |

1004. // | ** ** |

1005. // | ***** |

1006.

1007. { 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18 }, // 86 : V

1008. // | |

1009. // | ** ** |

1010. // | ** ** |

1011. // | ** ** |

1012. // | ** ** |

1013. // | ** ** |

1014. // | **** |

1015. // | ** |

1016.

1017. { 0x00, 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63 }, // 87 : W

1018. // | |

1019. // | ** ** |

1020. // | ** ** |

1021. // | ** ** |

1022. // | ** * ** |

1023. // | ******* |

1024. // | *** *** |

1025. // | ** ** |

1026.

1027. { 0x00, 0x63, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x63 }, // 88 : X

1028. // | |

1029. // | ** ** |
1030. // | ** ** |

1031. // | ** ** |

1032. // | *** |

1033. // | ** ** |

1034. // | ** ** |

1035. // | ** ** |

1036.

1037. { 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18 }, // 89 : Y

1038. // | |
1039. // | ** ** |

1040. // | ** ** |

1041. // | ** ** |

1042. // | **** |
1043. // | ** |

1044. // | ** |

1045. // | ** |

1046.

1047. { 0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E }, // 90 : Z

1048. // | |

1049. // | ****** |

1050. // | ** |

1051. // | ** |

1052. // | ** |

1053. // | ** |

1054. // | ** |

1055. // | ****** |

1056.

1057. { 0x00, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E }, // 91 : [

1058. // | |

1059. // | **** |

1060. // | ** |

1061. // | ** |

1062. // | ** |

1063. // | ** |

1064. // | ** |

1065. // | **** |

1066.

1067. { 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00 }, // 92 : \

1068. // | |

1069. // | |

1070. // | ** |

1071. // | ** |
1072. // | ** |

1073. // | ** |

1074. // | ** |

1075. // | |

1076.

1077. { 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78 }, // 93 : ]

1078. // | |

1079. // | **** |

1080. // | ** |
1081. // | ** |

1082. // | ** |

1083. // | ** |

1084. // | ** |
1085. // | **** |

1086.

1087. { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00 }, // 94 : ^

1088. // | |

1089. // | * |

1090. // | * * |

1091. // | * * |

1092. // | * * |

1093. // | |

1094. // | |

1095. // | |

1096.

1097. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F }, // 95 : _

1098. // | |

1099. // | |

1100. // | |

1101. // | |

1102. // | |

1103. // | |

1104. // | |

1105. // | ******* |

1106.

1107. { 0x00, 0x0C, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00 }, // 96 : `

1108. // | |

1109. // | ** |

1110. // | ** |

1111. // | ** |

1112. // | |

1113. // | |
1114. // | |

1115. // | |

1116.

1117. { 0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E }, // 97 : a

1118. // | |

1119. // | |

1120. // | |

1121. // | **** |

1122. // | ** |
1123. // | ***** |

1124. // | ** ** |

1125. // | ***** |

1126.
1127. { 0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C }, // 98 : b

1128. // | |

1129. // | ** |

1130. // | ** |

1131. // | ** |

1132. // | ***** |

1133. // | ** ** |

1134. // | ** ** |

1135. // | ***** |

1136.

1137. { 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C }, // 99 : c

1138. // | |

1139. // | |

1140. // | |

1141. // | **** |

1142. // | ** ** |

1143. // | ** |

1144. // | ** ** |

1145. // | **** |

1146.

1147. { 0x00, 0x06, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3E }, // 100 : d

1148. // | |

1149. // | ** |

1150. // | ** |

1151. // | ** |

1152. // | ***** |

1153. // | ** ** |

1154. // | ** ** |

1155. // | ***** |
1156.

1157. { 0x00, 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C }, // 101 : e

1158. // | |

1159. // | |

1160. // | |

1161. // | **** |

1162. // | ** ** |

1163. // | ****** |

1164. // | ** |
1165. // | **** |

1166.

1167. { 0x00, 0x1C, 0x36, 0x30, 0x30, 0x7C, 0x30, 0x30 }, // 102 : f

1168. // | |
1169. // | *** |

1170. // | ** ** |

1171. // | ** |

1172. // | ** |

1173. // | ***** |

1174. // | ** |

1175. // | ** |

1176.

1177. { 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x3C }, // 103 : g

1178. // | |

1179. // | |

1180. // | ***** |

1181. // | ** ** |

1182. // | ** ** |

1183. // | ***** |

1184. // | ** |

1185. // | **** |

1186.

1187. { 0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66 }, // 104 : h

1188. // | |

1189. // | ** |

1190. // | ** |

1191. // | ** |

1192. // | ***** |

1193. // | ** ** |

1194. // | ** ** |

1195. // | ** ** |

1196.

1197. { 0x00, 0x00, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3C }, // 105 : i
1198. // | |

1199. // | |

1200. // | ** |

1201. // | |

1202. // | ** |

1203. // | ** |

1204. // | ** |

1205. // | **** |

1206.
1207. { 0x00, 0x0C, 0x00, 0x0C, 0x0C, 0x6C, 0x6C, 0x38 }, // 106 : j

1208. // | |

1209. // | ** |

1210. // | |
1211. // | ** |

1212. // | ** |

1213. // | ** ** |

1214. // | ** ** |

1215. // | *** |

1216.

1217. { 0x00, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66 }, // 107 : k

1218. // | |

1219. // | ** |

1220. // | ** |

1221. // | ** ** |

1222. // | ** ** |

1223. // | **** |

1224. // | ** ** |

1225. // | ** ** |

1226.

1227. { 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 }, // 108 : l

1228. // | |

1229. // | ** |

1230. // | ** |

1231. // | ** |

1232. // | ** |

1233. // | ** |

1234. // | ** |

1235. // | ** |

1236.

1237. { 0x00, 0x00, 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x6B }, // 109 : m

1238. // | |

1239. // | |
1240. // | |

1241. // | ** ** |

1242. // | *** *** |

1243. // | ******* |

1244. // | ** * ** |

1245. // | ** * ** |

1246.

1247. { 0x00, 0x00, 0x00, 0x7C, 0x7E, 0x66, 0x66, 0x66 }, // 110 : n

1248. // | |
1249. // | |

1250. // | |

1251. // | ***** |

1252. // | ****** |
1253. // | ** ** |

1254. // | ** ** |

1255. // | ** ** |

1256.

1257. { 0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C }, // 111 : o

1258. // | |

1259. // | |

1260. // | |

1261. // | **** |

1262. // | ** ** |

1263. // | ** ** |

1264. // | ** ** |

1265. // | **** |

1266.

1267. { 0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60 }, // 112 : p

1268. // | |

1269. // | |

1270. // | ***** |

1271. // | ** ** |

1272. // | ** ** |

1273. // | ***** |

1274. // | ** |

1275. // | ** |

1276.

1277. { 0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x3C, 0x0D, 0x0F }, // 113 : q

1278. // | |

1279. // | |

1280. // | **** |

1281. // | ** ** |
1282. // | ** ** |

1283. // | **** |

1284. // | ** * |

1285. // | **** |

1286.

1287. { 0x00, 0x00, 0x00, 0x7C, 0x66, 0x66, 0x60, 0x60 }, // 114 : r

1288. // | |

1289. // | |

1290. // | |
1291. // | ***** |

1292. // | ** ** |

1293. // | ** ** |

1294. // | ** |
1295. // | ** |

1296.

1297. { 0x00, 0x00, 0x00, 0x3E, 0x40, 0x3C, 0x02, 0x7C }, // 115 : s

1298. // | |

1299. // | |

1300. // | |

1301. // | ***** |

1302. // | * |

1303. // | **** |

1304. // | * |

1305. // | ***** |

1306.

1307. { 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18 }, // 116 : t

1308. // | |

1309. // | |

1310. // | ** |

1311. // | ** |

1312. // | ****** |

1313. // | ** |

1314. // | ** |

1315. // | ** |

1316.

1317. { 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E }, // 117 : u

1318. // | |

1319. // | |

1320. // | |

1321. // | ** ** |

1322. // | ** ** |

1323. // | ** ** |
1324. // | ** ** |

1325. // | ***** |

1326.

1327. { 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x18 }, // 118 : v

1328. // | |

1329. // | |

1330. // | |

1331. // | |

1332. // | ** ** |
1333. // | ** ** |

1334. // | **** |

1335. // | ** |

1336.
1337. { 0x00, 0x00, 0x00, 0x63, 0x6B, 0x6B, 0x6B, 0x3E }, // 119 : w

1338. // | |

1339. // | |

1340. // | |

1341. // | ** ** |

1342. // | ** * ** |

1343. // | ** * ** |

1344. // | ** * ** |

1345. // | ***** |

1346.

1347. { 0x00, 0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66 }, // 120 : x

1348. // | |

1349. // | |

1350. // | |

1351. // | ** ** |

1352. // | **** |

1353. // | ** |

1354. // | **** |

1355. // | ** ** |

1356.

1357. { 0x00, 0x00, 0x00, 0x66, 0x66, 0x3E, 0x06, 0x3C }, // 121 : y

1358. // | |

1359. // | |

1360. // | |

1361. // | ** ** |

1362. // | ** ** |

1363. // | ***** |

1364. // | ** |

1365. // | **** |
1366.

1367. { 0x00, 0x00, 0x00, 0x3C, 0x0C, 0x18, 0x30, 0x3C }, // 122 : z

1368. // | |

1369. // | |

1370. // | |

1371. // | **** |

1372. // | ** |

1373. // | ** |

1374. // | ** |
1375. // | **** |

1376.

1377. { 0x00, 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0E }, // 123 : {

1378. // | |
1379. // | *** |

1380. // | ** |

1381. // | ** |

1382. // | ** |

1383. // | ** |

1384. // | ** |

1385. // | *** |

1386.

1387. { 0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18 }, // 124 : |

1388. // | |

1389. // | ** |

1390. // | ** |

1391. // | ** |

1392. // | |

1393. // | ** |

1394. // | ** |

1395. // | ** |

1396.

1397. { 0x00, 0x70, 0x18, 0x18, 0x0C, 0x18, 0x18, 0x70 }, // 125 : }

1398. // | |

1399. // | *** |

1400. // | ** |

1401. // | ** |

1402. // | ** |

1403. // | ** |

1404. // | ** |

1405. // | *** |

1406.

1407. { 0x00, 0x00, 0x00, 0x3A, 0x6C, 0x00, 0x00, 0x00 }, // 126 : ~
1408. // | |

1409. // | |

1410. // | |

1411. // | *** * |

1412. // | ** ** |

1413. // | |

1414. // | |

1415. // | |

1416.
1417. { 0x00, 0x08, 0x1C, 0x36, 0x63, 0x41, 0x41, 0x7F } // 127 :

1418. // | |

1419. // | * |

1420. // | *** |
1421. // | ** ** |

1422. // | ** ** |

1423. // | * * |

1424. // | * * |

1425. // | ******* |

1426.

1427.

1428. };

1429.

1430. // Define display string here

1431. const int charNum = 15;

1432. char string[charNum] = {'A','R','D','U','I','N','O',' ','R','U','L','E','S','!',' '};

1433.

1434. void effect_text(int delayt){

1435. fill(0x00);

1436. for (int ltr = 0; ltr < charNum; ltr++){// For each letter in string array

1437. for(int dist = 0; dist < 8; dist++) { //bring letter forward

1438. fill(0x00);//blank last row

1439. int rev = 0;

1440. for (int rw = 7; rw >= 0; rw--) {//copy rows

1441. cube[rev][dist] = bitswap(font_data[string[ltr]][rw]);

1442. rev++;

1443. }

1444. delay_ms(delayt);

1445. }

1446. }

1447. }

1448.

1449. unsigned char bitswap (unsigned char x)//Reverses a byte (so letters aren't backwards);
1450. { byte result;

1451.

1452. asm("mov __tmp_reg__, %[in] \n\t"

1453. "lsl __tmp_reg__ \n\t" /* shift out high bit to carry */

1454. "ror %[out] \n\t" /* rotate carry __tmp_reg__to low bit (eventually) */

1455. "lsl __tmp_reg__ \n\t" /* 2 */

1456. "ror %[out] \n\t"

1457. "lsl __tmp_reg__ \n\t" /* 3 */

1458. "ror %[out] \n\t"


1459. "lsl __tmp_reg__ \n\t" /* 4 */

1460. "ror %[out] \n\t"

1461.

1462. "lsl __tmp_reg__ \n\t" /* 5 */


1463. "ror %[out] \n\t"

1464. "lsl __tmp_reg__ \n\t" /* 6 */

1465. "ror %[out] \n\t"

1466. "lsl __tmp_reg__ \n\t" /* 7 */

1467. "ror %[out] \n\t"

1468. "lsl __tmp_reg__ \n\t" /* 8 */

1469. "ror %[out] \n\t"

1470. : [out] "=r" (result) : [in] "r" (x));

1471. return(result);

1472. }

1473.

1474. //

==========================================================================================

1475. // Effect functions

1476. //

==========================================================================================

1477.

1478. void effect_box_wamp(int delayt)

1479. {

1480. for(int k = 0; k < 3; k++){

1481. for(int i = 0; i < 4; i++){

1482. fill(0x00);

1483. box_filled(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

1484. delay_ms(delayt);

1485. }

1486. for(int i = 3; i >= 0; i--){

1487. fill(0x00);

1488. box_filled(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

1489. delay_ms(delayt);
1490. }

1491. }

1492.

1493. for(int k = 0; k < 3; k++){

1494. for(int i = 0; i < 4; i++){

1495. fill(0x00);

1496. box_walls(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

1497. delay_ms(delayt);

1498. }
1499. for(int i = 3; i >= 0; i--){

1500. fill(0x00);

1501. box_walls(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

1502. delay_ms(delayt);
1503. }

1504. }

1505.

1506. for(int k = 0; k < 3; k++){

1507. for(int i = 0; i < 4; i++){

1508. fill(0x00);

1509. box_wireframe(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

1510. delay_ms(delayt);

1511. }

1512. for(int i = 3; i >= 0; i--){

1513. fill(0x00);

1514. box_wireframe(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

1515. delay_ms(delayt);

1516. }

1517. }

1518. }

1519.

1520. void draw_positions_axis (char axis, unsigned char positions[64], int invert)

1521. {

1522. int x, y, p;

1523.

1524. fill(0x00);

1525.

1526. for (x=0; x<8; x++)

1527. {

1528. for (y=0; y<8; y++)

1529. {

1530. if (invert)

1531. {
1532. p = (7-positions[(x*8)+y]);

1533. } else

1534. {

1535. p = positions[(x*8)+y];

1536. }

1537.

1538. if (axis == AXIS_Z)

1539. setvoxel(x,y,p);

1540.
1541. if (axis == AXIS_Y)

1542. setvoxel(x,p,y);

1543.

1544. if (axis == AXIS_X)


1545. setvoxel(p,y,x);

1546. }

1547. }

1548.

1549. }

1550.

1551.

1552. void effect_boxside_randsend_parallel (char axis, int origin, int delayt, int mode)

1553. {

1554. int i;

1555. int done;

1556. unsigned char cubepos[64];

1557. unsigned char pos[64];

1558. int notdone = 1;

1559. int notdone2 = 1;

1560. int sent = 0;

1561.

1562. for (i=0;i<64;i++)

1563. {

1564. pos[i] = 0;

1565. }

1566.

1567. while (notdone)

1568. {

1569. if (mode == 1)

1570. {

1571. notdone2 = 1;

1572. while (notdone2 && sent<64)

1573. {
1574. i = rand()%64;

1575. if (pos[i] == 0)

1576. {

1577. sent++;

1578. pos[i] += 1;

1579. notdone2 = 0;

1580. }

1581. }

1582. } else if (mode == 2)


1583. {

1584. if (sent<64)

1585. {

1586. pos[sent] += 1;
1587. sent++;

1588. }

1589. }

1590.

1591. done = 0;

1592. for (i=0;i<64;i++)

1593. {

1594. if (pos[i] > 0 && pos[i] <7)

1595. {

1596. pos[i] += 1;

1597. }

1598.

1599. if (pos[i] == 7)

1600. done++;

1601. }

1602.

1603. if (done == 64)

1604. notdone = 0;

1605.

1606. for (i=0;i<64;i++)

1607. {

1608. if (origin == 0)

1609. {

1610. cubepos[i] = pos[i];

1611. } else

1612. {

1613. cubepos[i] = (7-pos[i]);

1614. }

1615. }
1616.

1617.

1618. delay_ms(delayt);

1619. draw_positions_axis(axis,cubepos,0);

1620.

1621. }

1622.

1623. }

1624.
1625.

1626. void effect_rain (int iterations)

1627. {

1628. int i, ii;


1629. int rnd_x;

1630. int rnd_y;

1631. int rnd_num;

1632.

1633. for (ii=0;ii<iterations;ii++)

1634. {

1635. rnd_num = rand()%4;

1636.

1637. for (i=0; i < rnd_num;i++)

1638. {

1639. rnd_x = rand()%8;

1640. rnd_y = rand()%8;

1641. setvoxel(rnd_x,rnd_y,7);

1642. }

1643.

1644. delay_ms(1000);

1645. shift(AXIS_Z,-1);

1646. }

1647. }

1648.

1649. // Set or clear exactly 512 voxels in a random order.

1650. void effect_random_filler (int delayt, int state)

1651. {

1652. int x,y,z;

1653. int loop = 0;

1654.

1655.

1656. if (state == 1)

1657. {
1658. fill(0x00);

1659. } else

1660. {

1661. fill(0xff);

1662. }

1663.

1664. while (loop<511)

1665. {

1666. x = rand()%8;
1667. y = rand()%8;

1668. z = rand()%8;

1669.
1670. if ((state == 0 && getvoxel(x,y,z) == 0x01) || (state == 1 && getvoxel(x

,y,z) == 0x00))

1671. {

1672. altervoxel(x,y,z,state);

1673. delay_ms(delayt);

1674. loop++;

1675. }

1676. }

1677. }

1678.

1679.

1680. void effect_blinky2()

1681. {

1682. int i,r;

1683. fill(0x00);

1684.

1685. for (r=0;r<2;r++)

1686. {

1687. i = 750;

1688. while (i>0)

1689. {

1690. fill(0x00);

1691. delay_ms(i);

1692.

1693. fill(0xff);

1694. delay_ms(100);

1695.

1696. i = i - (15+(1000/(i/10)));

1697. }
1698.

1699. delay_ms(1000);

1700.

1701. i = 750;

1702. while (i>0)

1703. {

1704. fill(0x00);

1705. delay_ms(751-i);

1706.
1707. fill(0xff);

1708. delay_ms(100);

1709.

1710. i = i - (15+(1000/(i/10)));
1711. }

1712. }

1713.

1714. }

1715.

1716. // Draw a plane on one axis and send it back and forth once.

1717. void effect_planboing (int plane, int speedd)

1718. {

1719. int i;

1720. for (i=0;i<8;i++)

1721. {

1722. fill(0x00);

1723. setplane(plane, i);

1724. delay_ms(speedd);

1725. }

1726.

1727. for (i=7;i>=0;i--)

1728. {

1729. fill(0x00);

1730. setplane(plane,i);

1731. delay_ms(speedd);

1732. }

1733. }

1734.

1735.

1736. //

==========================================================================================

1737. // Draw functions

1738. //
==========================================================================================

1739.

1740.

1741. // Set a single voxel to ON

1742. void setvoxel(int x, int y, int z)

1743. {

1744. if (inrange(x,y,z))

1745. cube[z][y] |= (1 << x);

1746. }
1747.

1748.

1749. // Set a single voxel to ON

1750. void clrvoxel(int x, int y, int z)


1751. {

1752. if (inrange(x,y,z))

1753. cube[z][y] &= ~(1 << x);

1754. }

1755.

1756.

1757.

1758. // This function validates that we are drawing inside the cube.

1759. unsigned char inrange(int x, int y, int z)

1760. {

1761. if (x >= 0 && x < 8 && y >= 0 && y < 8 && z >= 0 && z < 8)

1762. {

1763. return 0x01;

1764. } else

1765. {

1766. // One of the coordinates was outside the cube.

1767. return 0x00;

1768. }

1769. }

1770.

1771. // Get the current status of a voxel

1772. unsigned char getvoxel(int x, int y, int z)

1773. {

1774. if (inrange(x,y,z))

1775. {

1776. if (cube[z][y] & (1 << x))

1777. {

1778. return 0x01;

1779. } else
1780. {

1781. return 0x00;

1782. }

1783. } else

1784. {

1785. return 0x00;

1786. }

1787. }

1788.
1789. // In some effect we want to just take bool and write it to a voxel

1790. // this function calls the apropriate voxel manipulation function.

1791. void altervoxel(int x, int y, int z, int state)

1792. {
1793. if (state == 1)

1794. {

1795. setvoxel(x,y,z);

1796. } else

1797. {

1798. clrvoxel(x,y,z);

1799. }

1800. }

1801.

1802. // Flip the state of a voxel.

1803. // If the voxel is 1, its turned into a 0, and vice versa.

1804. void flpvoxel(int x, int y, int z)

1805. {

1806. if (inrange(x, y, z))

1807. cube[z][y] ^= (1 << x);

1808. }

1809.

1810. // Makes sure x1 is alwas smaller than x2

1811. // This is usefull for functions that uses for loops,

1812. // to avoid infinite loops

1813. void argorder(int ix1, int ix2, int *ox1, int *ox2)

1814. {

1815. if (ix1>ix2)

1816. {

1817. int tmp;

1818. tmp = ix1;

1819. ix1= ix2;

1820. ix2 = tmp;

1821. }
1822. *ox1 = ix1;

1823. *ox2 = ix2;

1824. }

1825.

1826. // Sets all voxels along a X/Y plane at a given point

1827. // on axis Z

1828. void setplane_z (int z)

1829. {

1830. int i;
1831. if (z>=0 && z<8)

1832. {

1833. for (i=0;i<8;i++)

1834. cube[z][i] = 0xff;


1835. }

1836. }

1837.

1838. // Clears voxels in the same manner as above

1839. void clrplane_z (int z)

1840. {

1841. int i;

1842. if (z>=0 && z<8)

1843. {

1844. for (i=0;i<8;i++)

1845. cube[z][i] = 0x00;

1846. }

1847. }

1848.

1849. void setplane_x (int x)

1850. {

1851. int z;

1852. int y;

1853. if (x>=0 && x<8)

1854. {

1855. for (z=0;z<8;z++)

1856. {

1857. for (y=0;y<8;y++)

1858. {

1859. cube[z][y] |= (1 << x);

1860. }

1861. }

1862. }

1863. }
1864.

1865. void clrplane_x (int x)

1866. {

1867. int z;

1868. int y;

1869. if (x>=0 && x<8)

1870. {

1871. for (z=0;z<8;z++)

1872. {
1873. for (y=0;y<8;y++)

1874. {

1875. cube[z][y] &= ~(1 << x);

1876. }
1877. }

1878. }

1879. }

1880.

1881. void setplane_y (int y)

1882. {

1883. int z;

1884. if (y>=0 && y<8)

1885. {

1886. for (z=0;z<8;z++)

1887. cube[z][y] = 0xff;

1888. }

1889. }

1890.

1891. void clrplane_y (int y)

1892. {

1893. int z;

1894. if (y>=0 && y<8)

1895. {

1896. for (z=0;z<8;z++)

1897. cube[z][y] = 0x00;

1898. }

1899. }

1900.

1901. void setplane (char axis, unsigned char i)

1902. {

1903. switch (axis)

1904. {

1905. case AXIS_X:


1906. setplane_x(i);

1907. break;

1908.

1909. case AXIS_Y:

1910. setplane_y(i);

1911. break;

1912.

1913. case AXIS_Z:

1914. setplane_z(i);
1915. break;

1916. }

1917. }

1918.
1919. void clrplane (char axis, unsigned char i)

1920. {

1921. switch (axis)

1922. {

1923. case AXIS_X:

1924. clrplane_x(i);

1925. break;

1926.

1927. case AXIS_Y:

1928. clrplane_y(i);

1929. break;

1930.

1931. case AXIS_Z:

1932. clrplane_z(i);

1933. break;

1934. }

1935. }

1936.

1937. // Fill a value into all 64 byts of the cube buffer

1938. // Mostly used for clearing. fill(0x00)

1939. // or setting all on. fill(0xff)

1940. void fill (unsigned char pattern)

1941. {

1942. int z;

1943. int y;

1944. for (z=0;z<8;z++)

1945. {

1946. for (y=0;y<8;y++)

1947. {
1948. cube[z][y] = pattern;

1949. }

1950. }

1951. }

1952.

1953.

1954.

1955. // Draw a box with all walls drawn and all voxels inside set

1956. void box_filled(int x1, int y1, int z1, int x2, int y2, int z2)
1957. {

1958. int iy;

1959. int iz;

1960.
1961. argorder(x1, x2, &x1, &x2);

1962. argorder(y1, y2, &y1, &y2);

1963. argorder(z1, z2, &z1, &z2);

1964.

1965. for (iz=z1;iz<=z2;iz++)

1966. {

1967. for (iy=y1;iy<=y2;iy++)

1968. {

1969. cube[iz][iy] |= byteline(x1,x2);

1970. }

1971. }

1972.

1973. }

1974.

1975. // Darw a hollow box with side walls.

1976. void box_walls(int x1, int y1, int z1, int x2, int y2, int z2)

1977. {

1978. int iy;

1979. int iz;

1980.

1981. argorder(x1, x2, &x1, &x2);

1982. argorder(y1, y2, &y1, &y2);

1983. argorder(z1, z2, &z1, &z2);

1984.

1985. for (iz=z1;iz<=z2;iz++)

1986. {

1987. for (iy=y1;iy<=y2;iy++)

1988. {

1989. if (iy == y1 || iy == y2 || iz == z1 || iz == z2)


1990. {

1991. cube[iz][iy] = byteline(x1,x2);

1992. } else

1993. {

1994. cube[iz][iy] |= ((0x01 << x1) | (0x01 << x2));

1995. }

1996. }

1997. }

1998.
1999. }

2000.

2001. // Draw a wireframe box. This only draws the corners and edges,

2002. // no walls.
2003. void box_wireframe(int x1, int y1, int z1, int x2, int y2, int z2)

2004. {

2005. int iy;

2006. int iz;

2007.

2008. argorder(x1, x2, &x1, &x2);

2009. argorder(y1, y2, &y1, &y2);

2010. argorder(z1, z2, &z1, &z2);

2011.

2012. // Lines along X axis

2013. cube[z1][y1] = byteline(x1,x2);

2014. cube[z1][y2] = byteline(x1,x2);

2015. cube[z2][y1] = byteline(x1,x2);

2016. cube[z2][y2] = byteline(x1,x2);

2017.

2018. // Lines along Y axis

2019. for (iy=y1;iy<=y2;iy++)

2020. {

2021. setvoxel(x1,iy,z1);

2022. setvoxel(x1,iy,z2);

2023. setvoxel(x2,iy,z1);

2024. setvoxel(x2,iy,z2);

2025. }

2026.

2027. // Lines along Z axis

2028. for (iz=z1;iz<=z2;iz++)

2029. {

2030. setvoxel(x1,y1,iz);

2031. setvoxel(x1,y2,iz);
2032. setvoxel(x2,y1,iz);

2033. setvoxel(x2,y2,iz);

2034. }

2035.

2036. }

2037.

2038. // Returns a byte with a row of 1's drawn in it.

2039. // byteline(2,5) gives 0b00111100

2040. char byteline (int start, int end)


2041. {

2042. return ((0xff<<start) & ~(0xff<<(end+1)));

2043. }

2044.
2045. // Flips a byte 180 degrees.

2046. // MSB becomes LSB, LSB becomes MSB.

2047. char flipbyte (char byte)

2048. {

2049. char flop = 0x00;

2050.

2051. flop = (flop & 0b11111110) | (0b00000001 & (byte >> 7));

2052. flop = (flop & 0b11111101) | (0b00000010 & (byte >> 5));

2053. flop = (flop & 0b11111011) | (0b00000100 & (byte >> 3));

2054. flop = (flop & 0b11110111) | (0b00001000 & (byte >> 1));

2055. flop = (flop & 0b11101111) | (0b00010000 & (byte << 1));

2056. flop = (flop & 0b11011111) | (0b00100000 & (byte << 3));

2057. flop = (flop & 0b10111111) | (0b01000000 & (byte << 5));

2058. flop = (flop & 0b01111111) | (0b10000000 & (byte << 7));

2059. return flop;

2060. }

2061.

2062. // Draw a line between any coordinates in 3d space.

2063. // Uses integer values for input, so dont expect smooth animations.

2064. void line(int x1, int y1, int z1, int x2, int y2, int z2)

2065. {

2066. float xy; // how many voxels do we move on the y axis for each step on the

x axis

2067. float xz; // how many voxels do we move on the y axis for each step on the

x axis

2068. unsigned char x,y,z;

2069. unsigned char lasty,lastz;

2070.

2071. // We always want to draw the line from x=0 to x=7.


2072. // If x1 is bigget than x2, we need to flip all the values.

2073. if (x1>x2)

2074. {

2075. int tmp;

2076. tmp = x2; x2 = x1; x1 = tmp;

2077. tmp = y2; y2 = y1; y1 = tmp;

2078. tmp = z2; z2 = z1; z1 = tmp;

2079. }

2080.
2081.

2082. if (y1>y2)

2083. {

2084. xy = (float)(y1-y2)/(float)(x2-x1);
2085. lasty = y2;

2086. } else

2087. {

2088. xy = (float)(y2-y1)/(float)(x2-x1);

2089. lasty = y1;

2090. }

2091.

2092. if (z1>z2)

2093. {

2094. xz = (float)(z1-z2)/(float)(x2-x1);

2095. lastz = z2;

2096. } else

2097. {

2098. xz = (float)(z2-z1)/(float)(x2-x1);

2099. lastz = z1;

2100. }

2101.

2102.

2103.

2104. // For each step of x, y increments by:

2105. for (x = x1; x<=x2;x++)

2106. {

2107. y = (xy*(x-x1))+y1;

2108. z = (xz*(x-x1))+z1;

2109. setvoxel(x,y,z);

2110. }

2111.

2112. }

2113.
2114. // Delay loop.

2115. // This is not calibrated to milliseconds,

2116. // but we had allready made to many effects using this

2117. // calibration when we figured it might be a good idea

2118. // to calibrate it.

2119. void delay_ms(uint16_t x)

2120. {

2121. uint8_t y, z;

2122. for ( ; x > 0 ; x--){


2123. for ( y = 0 ; y < 90 ; y++){

2124. for ( z = 0 ; z < 6 ; z++){

2125. asm volatile ("nop");

2126. }
2127. }

2128. }

2129. }

2130.

2131.

2132.

2133. // Shift the entire contents of the cube along an axis

2134. // This is great for effects where you want to draw something

2135. // on one side of the cube and have it flow towards the other

2136. // side. Like rain flowing down the Z axiz.

2137. void shift (char axis, int direction)

2138. {

2139. int i, x ,y;

2140. int ii, iii;

2141. int state;

2142.

2143. for (i = 0; i < 8; i++)

2144. {

2145. if (direction == -1)

2146. {

2147. ii = i;

2148. } else

2149. {

2150. ii = (7-i);

2151. }

2152.

2153.

2154. for (x = 0; x < 8; x++)

2155. {
2156. for (y = 0; y < 8; y++)

2157. {

2158. if (direction == -1)

2159. {

2160. iii = ii+1;

2161. } else

2162. {

2163. iii = ii-1;

2164. }
2165.

2166. if (axis == AXIS_Z)

2167. {

2168. state = getvoxel(x,y,iii);


2169. altervoxel(x,y,ii,state);

2170. }

2171.

2172. if (axis == AXIS_Y)

2173. {

2174. state = getvoxel(x,iii,y);

2175. altervoxel(x,ii,y,state);

2176. }

2177.

2178. if (axis == AXIS_X)

2179. {

2180. state = getvoxel(iii,y,x);

2181. altervoxel(ii,y,x,state);

2182. }

2183. }

2184. }

2185. }

2186.

2187. if (direction == -1)

2188. {

2189. i = 7;

2190. } else

2191. {

2192. i = 0;

2193. }

2194.

2195. for (x = 0; x < 8; x++)

2196. {

2197. for (y = 0; y < 8; y++)


2198. {

2199. if (axis == AXIS_Z)

2200. clrvoxel(x,y,i);

2201.

2202. if (axis == AXIS_Y)

2203. clrvoxel(x,i,y);

2204.

2205. if (axis == AXIS_X)

2206. clrvoxel(i,y,x);
2207. }

2208. }
2209. }
RAW Paste Data

/**********************************************************
*****************************

* Name : LED CUBE 8x8x8 74HC595

* By : Liam Jackson

Based on code by Joseph Francis (74hc595 SPI)

and by chr at instructables

http://www.instructables.com/id/Led-Cube-8x8x8/step70/Run-the-
cube-on-an-Arduino/

Font found somewhere

***********************************************************
*****************************/

#include <TimerOne.h>

#include <string.h>

#define AXIS_X 1

#define AXIS_Y 2

#define AXIS_Z 3

//--- Pin connected to ST_CP of 74HC595

int latchPin = 10;


//--- Pin connected to SH_CP of 74HC595

int clockPin = 13;

//--- Pin connected to DS of 74HC595

int dataPin = 11;

//--- Used for faster latching

int latchPinPORTB = latchPin - 8;

//holds value for all the pins, [x][y][z]

byte cube[8][8];

//Counts through the layers

int current_layer = 0;

//--- This process is run by the timer and does the PWM control

void iProcess(){

//last layer store

int oldLayerBit = current_layer + 2;

//increment layer count

current_layer++;

if(current_layer >= 8){

current_layer = 0;

}
//--- Run through all the shift register values and send them (last one
first)

// latching in the process

latchOff();

for (int i = 0 ; i < 8 ; i++){

spi_transfer(cube[current_layer][i]);

//Hide the old layer

digitalWrite(oldLayerBit, LOW);

//New data on the pins

latchOn();

//new layer high

digitalWrite(current_layer + 2, HIGH);

//--- Direct port access latching

void latchOn(){

bitSet(PORTB,latchPinPORTB);

void latchOff(){

bitClear(PORTB,latchPinPORTB);

}
//--- Used to setup SPI based on current pin setup

// this is called in the setup routine;

void setupSPI(){

byte clr;

SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master

SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits

clr=SPSR; // clear SPI status reg

clr=SPDR; // clear SPI data reg

SPSR |= (1<<SPI2X); // set prescaler bits

delay(10);

//--- The really fast SPI version of shiftOut

byte spi_transfer(byte data)

SPDR = data; // Start the transmission

loop_until_bit_is_set(SPSR, SPIF);

return SPDR; // return the received byte, we don't need


that

void setup() {

Serial.begin(9600);
//layer pins

for(int i = 2; i < 10; i++)

pinMode(i, OUTPUT);

pinMode(latchPin, OUTPUT);

pinMode(clockPin, OUTPUT);

pinMode(dataPin, OUTPUT);

digitalWrite(latchPin,LOW);

digitalWrite(dataPin,LOW);

digitalWrite(clockPin,LOW);

//--- Setup to run SPI

setupSPI();

//--- Activate the PWM timer

Timer1.initialize(100); // Timer for updating pwm pins

Timer1.attachInterrupt(iProcess);

}
void loop(){

int i,x,y,z;

while (true)

effect_text(800);

effect_box_wamp(1000);

effect_rain(100);

effect_planboing(AXIS_Z, 400);

effect_planboing(AXIS_Y, 400);

effect_planboing(AXIS_X, 400);

effect_blinky2();

effect_random_filler(75,1);

effect_random_filler(75,0);

effect_boxside_randsend_parallel (AXIS_X, 0, 150, 1);

effect_boxside_randsend_parallel (AXIS_X, 1, 150, 1);

effect_boxside_randsend_parallel (AXIS_Y, 0, 150, 1);


effect_boxside_randsend_parallel (AXIS_Y, 1, 150, 1);

effect_boxside_randsend_parallel (AXIS_Z, 0, 150, 1);

effect_boxside_randsend_parallel (AXIS_Z, 1, 150, 1);

//
===========================================================
===============================

// TEXT Functions

//
===========================================================
===============================

char font_data[128][8] = {

{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0 :

// | |

// | |

// | |

// | |

// | |

// | |

// | |

// | |
{ 0x00, 0x3E, 0x41, 0x55, 0x41, 0x55, 0x49, 0x3E }, // 1 :

// | |

// | ***** |

// | * *|

// | ****|

// | * *|

// | ****|

// | * * *|

// | ***** |

{ 0x00, 0x3E, 0x7F, 0x6B, 0x7F, 0x6B, 0x77, 0x3E }, // 2 :

// | |

// | ***** |

// | ******* |

// | ** * ** |

// | ******* |

// | ** * ** |

// | *** *** |

// | ***** |

{ 0x00, 0x22, 0x77, 0x7F, 0x7F, 0x3E, 0x1C, 0x08 }, // 3 :

// | |
// | * * |

// | *** *** |

// | ******* |

// | ******* |

// | ***** |

// | *** |

// | * |

{ 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08 }, // 4 :

// | |

// | * |

// | *** |

// | ***** |

// | ******* |

// | ***** |

// | *** |

// | * |

{ 0x00, 0x08, 0x1C, 0x2A, 0x7F, 0x2A, 0x08, 0x1C }, // 5 :

// | |

// | * |

// | *** |

// | *** |
// | ******* |

// | *** |

// | * |

// | *** |

{ 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x08, 0x1C }, // 6 :

// | |

// | * |

// | *** |

// | ***** |

// | ******* |

// | ***** |

// | * |

// | *** |

{ 0x00, 0x00, 0x1C, 0x3E, 0x3E, 0x3E, 0x1C, 0x00 }, // 7 :

// | |

// | |

// | *** |

// | ***** |

// | ***** |

// | ***** |

// | *** |
// | |

{ 0xFF, 0xFF, 0xE3, 0xC1, 0xC1, 0xC1, 0xE3, 0xFF }, // 8 :

// | ******** |

// | ******** |

// | *** ** |

// | ** *|

// | ** *|

// | ** *|

// | *** ** |

// | ******** |

{ 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00 }, // 9 :

// | |

// | |

// | *** |

// | * * |

// | * * |

// | * * |

// | *** |

// | |

{ 0xFF, 0xFF, 0xE3, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF }, // 10 :


// | ******** |

// | ******** |

// | *** ** |

// | ** *** * |

// | ** *** * |

// | ** *** * |

// | *** ** |

// | ******** |

{ 0x00, 0x0F, 0x03, 0x05, 0x39, 0x48, 0x48, 0x30 }, // 11 :

// | |

// | **** |

// | ** |

// | **|

// | *** * |

// | * * |

// | * * |

// | ** |

{ 0x00, 0x08, 0x3E, 0x08, 0x1C, 0x22, 0x22, 0x1C }, // 12 :


// | |

// | * |

// | ***** |

// | * |

// | *** |

// | * * |

// | * * |

// | *** |

{ 0x00, 0x18, 0x14, 0x10, 0x10, 0x30, 0x70, 0x60 }, // 13 :

// | |

// | ** |

// | ** |

// | * |

// | * |

// | ** |

// | *** |

// | ** |

{ 0x00, 0x0F, 0x19, 0x11, 0x13, 0x37, 0x76, 0x60 }, // 14 :


// | |

// | **** |

// | ** * |

// | * *|

// | * ** |

// | ** *** |

// | *** ** |

// | ** |

{ 0x00, 0x08, 0x2A, 0x1C, 0x77, 0x1C, 0x2A, 0x08 }, // 15 :

// | |

// | * |

// | *** |

// | *** |

// | *** *** |

// | *** |

// | *** |

// | * |

{ 0x00, 0x60, 0x78, 0x7E, 0x7F, 0x7E, 0x78, 0x60 }, // 16 :

// | |

// | ** |
// | **** |

// | ****** |

// | ******* |

// | ****** |

// | **** |

// | ** |

{ 0x00, 0x03, 0x0F, 0x3F, 0x7F, 0x3F, 0x0F, 0x03 }, // 17 :

// | |

// | ** |

// | **** |

// | ****** |

// | ******* |

// | ****** |

// | **** |

// | ** |

{ 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x08 }, // 18 :

// | |

// | * |

// | *** |

// | *** |

// | * |
// | *** |

// | *** |

// | * |

{ 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66 }, // 19 :

// | |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | |

// | ** ** |

// | ** ** |

{ 0x00, 0x3F, 0x65, 0x65, 0x3D, 0x05, 0x05, 0x05 }, // 20 :

// | |

// | ****** |

// | ** * * |

// | ** * * |

// | **** * |

// | **|

// | **|

// | **|
{ 0x00, 0x0C, 0x32, 0x48, 0x24, 0x12, 0x4C, 0x30 }, // 21 :

// | |

// | ** |

// | ** * |

// | * * |

// | * * |

// | * * |

// | * ** |

// | ** |

{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }, // 22 :

// | |

// | |

// | |

// | |

// | |

// | ******* |

// | ******* |

// | ******* |

{ 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x3E }, // 23 :

// | |
// | * |

// | *** |

// | *** |

// | * |

// | *** |

// | *** |

// | ***** |

{ 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x1C, 0x1C, 0x1C }, // 24 :

// | |

// | * |

// | *** |

// | ***** |

// | ******* |

// | *** |

// | *** |

// | *** |

{ 0x00, 0x1C, 0x1C, 0x1C, 0x7F, 0x3E, 0x1C, 0x08 }, // 25 :

// | |

// | *** |

// | *** |

// | *** |
// | ******* |

// | ***** |

// | *** |

// | * |

{ 0x00, 0x08, 0x0C, 0x7E, 0x7F, 0x7E, 0x0C, 0x08 }, // 26 :

// | |

// | * |

// | ** |

// | ****** |

// | ******* |

// | ****** |

// | ** |

// | * |

{ 0x00, 0x08, 0x18, 0x3F, 0x7F, 0x3F, 0x18, 0x08 }, // 27 :

// | |

// | * |

// | ** |

// | ****** |

// | ******* |

// | ****** |

// | ** |
// | * |

{ 0x00, 0x00, 0x00, 0x70, 0x70, 0x70, 0x7F, 0x7F }, // 28 :

// | |

// | |

// | |

// | *** |

// | *** |

// | *** |

// | ******* |

// | ******* |

{ 0x00, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00 }, // 29 :

// | |

// | |

// | ** |

// | * * |

// | ******* |

// | * * |

// | ** |

// | |

{ 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x3E, 0x7F, 0x7F }, // 30 : -


// | |

// | * |

// | *** |

// | *** |

// | ***** |

// | ***** |

// | ******* |

// | ******* |

{ 0x00, 0x7F, 0x7F, 0x3E, 0x3E, 0x1C, 0x1C, 0x08 }, // 31 :

// | |

// | ******* |

// | ******* |

// | ***** |

// | ***** |

// | *** |

// | *** |

// | * |

{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32 :

// | |

// | |

// | |
// | |

// | |

// | |

// | |

// | |

{ 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18 }, // 33 : !

// | |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | |

// | ** |

{ 0x00, 0x36, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00 }, // 34 : "

// | |

// | ** ** |

// | ** ** |

// | ** |

// | |

// | |
// | |

// | |

{ 0x00, 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36 }, // 35 : #

// | |

// | ** ** |

// | ** ** |

// | ******* |

// | ** ** |

// | ******* |

// | ** ** |

// | ** ** |

{ 0x00, 0x08, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x08 }, // 36 : $

// | |

// | * |

// | **** |

// | * |

// | *** |

// | * |

// | **** |

// | * |
{ 0x00, 0x60, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x06 }, // 37 : %

// | |

// | ** |

// | ** ** |

// | ** |

// | ** |

// | ** |

// | ** ** |

// | ** |

{ 0x00, 0x3C, 0x66, 0x3C, 0x28, 0x65, 0x66, 0x3F }, // 38 : &

// | |

// | **** |

// | ** ** |

// | **** |

// | ** |

// | ** * * |

// | ** ** |

// | ****** |

{ 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00 }, // 39 : '

// | |

// | ** |
// | ** |

// | ** |

// | ** |

// | |

// | |

// | |

{ 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60 }, // 40 : (

// | |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06 }, // 41 : )

// | |

// | ** |

// | ** |

// | ** |

// | ** |
// | ** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x36, 0x1C, 0x7F, 0x1C, 0x36, 0x00 }, // 42 : *

// | |

// | |

// | ** ** |

// | *** |

// | ******* |

// | *** |

// | ** ** |

// | |

{ 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00 }, // 43 : +

// | |

// | |

// | * |

// | * |

// | ***** |

// | * |

// | * |

// | |
{ 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60 }, // 44 : ,

// | |

// | |

// | |

// | |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00 }, // 45 : -

// | |

// | |

// | |

// | |

// | **** |

// | |

// | |

// | |

{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60 }, // 46 : .

// | |
// | |

// | |

// | |

// | |

// | |

// | ** |

// | ** |

{ 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00 }, // 47 : /

// | |

// | |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | |

{ 0x00, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C }, // 48 : 0

// | |

// | **** |

// | ** ** |

// | ** *** |
// | *** ** |

// | ** ** |

// | ** ** |

// | **** |

{ 0x00, 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x7E }, // 49 : 1

// | |

// | ** |

// | ** |

// | *** |

// | ** |

// | ** |

// | ** |

// | ****** |

{ 0x00, 0x3C, 0x66, 0x06, 0x0C, 0x30, 0x60, 0x7E }, // 50 : 2

// | |

// | **** |

// | ** ** |

// | ** |

// | ** |

// | ** |

// | ** |
// | ****** |

{ 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C }, // 51 : 3

// | |

// | **** |

// | ** ** |

// | ** |

// | *** |

// | ** |

// | ** ** |

// | **** |

{ 0x00, 0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C }, // 52 : 4

// | |

// | ** |

// | *** |

// | * ** |

// | * ** |

// | ****** |

// | ** |

// | ** |

{ 0x00, 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C }, // 53 : 5


// | |

// | ****** |

// | ** |

// | ***** |

// | ** |

// | ** |

// | ** ** |

// | **** |

{ 0x00, 0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C }, // 54 : 6

// | |

// | **** |

// | ** ** |

// | ** |

// | ***** |

// | ** ** |

// | ** ** |

// | **** |

{ 0x00, 0x7E, 0x66, 0x0C, 0x0C, 0x18, 0x18, 0x18 }, // 55 : 7

// | |

// | ****** |

// | ** ** |
// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C }, // 56 : 8

// | |

// | **** |

// | ** ** |

// | ** ** |

// | **** |

// | ** ** |

// | ** ** |

// | **** |

{ 0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C }, // 57 : 9

// | |

// | **** |

// | ** ** |

// | ** ** |

// | ***** |

// | ** |
// | ** ** |

// | **** |

{ 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00 }, // 58 : :

// | |

// | |

// | ** |

// | ** |

// | |

// | ** |

// | ** |

// | |

{ 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30 }, // 59 : ;

// | |

// | |

// | ** |

// | ** |

// | |

// | ** |

// | ** |

// | ** |
{ 0x00, 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06 }, // 60 : <

// | |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00 }, // 61 : =

// | |

// | |

// | |

// | **** |

// | |

// | **** |

// | |

// | |

{ 0x00, 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60 }, // 62 : >

// | |

// | ** |
// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18 }, // 63 : ?

// | |

// | **** |

// | ** ** |

// | ** |

// | *** |

// | ** |

// | |

// | ** |

{ 0x00, 0x38, 0x44, 0x5C, 0x58, 0x42, 0x3C, 0x00 }, // 64 : @

// | |

// | *** |

// | * * |

// | * *** |

// | * ** |
// | * * |

// | **** |

// | |

{ 0x00, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66 }, // 65 : A

// | |

// | **** |

// | ** ** |

// | ** ** |

// | ****** |

// | ** ** |

// | ** ** |

// | ** ** |

{ 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C }, // 66 : B

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |
{ 0x00, 0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C }, // 67 : C

// | |

// | **** |

// | ** ** |

// | ** |

// | ** |

// | ** |

// | ** ** |

// | **** |

{ 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C }, // 68 : D

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ***** |

{ 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x7E }, // 69 : E

// | |
// | ****** |

// | ** |

// | ** |

// | ***** |

// | ** |

// | ** |

// | ****** |

{ 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60 }, // 70 : F

// | |

// | ****** |

// | ** |

// | ** |

// | ***** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x3C, 0x66, 0x60, 0x60, 0x6E, 0x66, 0x3C }, // 71 : G

// | |

// | **** |

// | ** ** |

// | ** |
// | ** |

// | ** *** |

// | ** ** |

// | **** |

{ 0x00, 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66 }, // 72 : H

// | |

// | ** ** |

// | ** ** |

// | ** ** |

// | ****** |

// | ** ** |

// | ** ** |

// | ** ** |

{ 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C }, // 73 : I

// | |

// | **** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |
// | **** |

{ 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x6C, 0x6C, 0x38 }, // 74 : J

// | |

// | **** |

// | ** |

// | ** |

// | ** |

// | ** ** |

// | ** ** |

// | *** |

{ 0x00, 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66 }, // 75 : K

// | |

// | ** ** |

// | ** ** |

// | **** |

// | *** |

// | **** |

// | ** ** |

// | ** ** |

{ 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E }, // 76 : L


// | |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ****** |

{ 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63 }, // 77 : M

// | |

// | ** ** |

// | *** *** |

// | ******* |

// | ** * ** |

// | ** ** |

// | ** ** |

// | ** ** |

{ 0x00, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x63, 0x63 }, // 78 : N

// | |

// | ** ** |

// | *** ** |
// | **** ** |

// | ** **** |

// | ** *** |

// | ** ** |

// | ** ** |

{ 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C }, // 79 : O

// | |

// | **** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | **** |

{ 0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60 }, // 80 : P

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ***** |
// | ** |

// | ** |

{ 0x00, 0x3C, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x06 }, // 81 : Q

// | |

// | **** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** *** |

// | **** |

// | ** |

{ 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x78, 0x6C, 0x66 }, // 82 : R

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |

// | **** |

// | ** ** |

// | ** ** |
{ 0x00, 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C }, // 83 : S

// | |

// | **** |

// | ** ** |

// | ** |

// | **** |

// | ** |

// | ** ** |

// | **** |

{ 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x18 }, // 84 : T

// | |

// | ****** |

// | * ** * |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E }, // 85 : U

// | |

// | ** ** |
// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ***** |

{ 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18 }, // 86 : V

// | |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** ** |

// | **** |

// | ** |

{ 0x00, 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63 }, // 87 : W

// | |

// | ** ** |

// | ** ** |

// | ** ** |

// | ** * ** |
// | ******* |

// | *** *** |

// | ** ** |

{ 0x00, 0x63, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x63 }, // 88 : X

// | |

// | ** ** |

// | ** ** |

// | ** ** |

// | *** |

// | ** ** |

// | ** ** |

// | ** ** |

{ 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18 }, // 89 : Y

// | |

// | ** ** |

// | ** ** |

// | ** ** |

// | **** |

// | ** |

// | ** |

// | ** |
{ 0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E }, // 90 : Z

// | |

// | ****** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ****** |

{ 0x00, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E }, // 91 : [

// | |

// | **** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | **** |

{ 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00 }, // 92 : \

// | |
// | |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | |

{ 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78 }, // 93 : ]

// | |

// | **** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | **** |

{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00 }, // 94 : ^

// | |

// | * |

// | ** |

// | * * |
// | * *|

// | |

// | |

// | |

{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F }, // 95 : _

// | |

// | |

// | |

// | |

// | |

// | |

// | |

// | ******* |

{ 0x00, 0x0C, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00 }, // 96 : `

// | |

// | ** |

// | ** |

// | ** |

// | |

// | |

// | |
// | |

{ 0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E }, // 97 : a

// | |

// | |

// | |

// | **** |

// | ** |

// | ***** |

// | ** ** |

// | ***** |

{ 0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C }, // 98 : b

// | |

// | ** |

// | ** |

// | ** |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |

{ 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C }, // 99 : c


// | |

// | |

// | |

// | **** |

// | ** ** |

// | ** |

// | ** ** |

// | **** |

{ 0x00, 0x06, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3E }, // 100 : d

// | |

// | ** |

// | ** |

// | ** |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |

{ 0x00, 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C }, // 101 : e

// | |

// | |

// | |
// | **** |

// | ** ** |

// | ****** |

// | ** |

// | **** |

{ 0x00, 0x1C, 0x36, 0x30, 0x30, 0x7C, 0x30, 0x30 }, // 102 : f

// | |

// | *** |

// | ** ** |

// | ** |

// | ** |

// | ***** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x3C }, // 103 : g

// | |

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |
// | ** |

// | **** |

{ 0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66 }, // 104 : h

// | |

// | ** |

// | ** |

// | ** |

// | ***** |

// | ** ** |

// | ** ** |

// | ** ** |

{ 0x00, 0x00, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3C }, // 105 : i

// | |

// | |

// | ** |

// | |

// | ** |

// | ** |

// | ** |

// | **** |
{ 0x00, 0x0C, 0x00, 0x0C, 0x0C, 0x6C, 0x6C, 0x38 }, // 106 : j

// | |

// | ** |

// | |

// | ** |

// | ** |

// | ** ** |

// | ** ** |

// | *** |

{ 0x00, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66 }, // 107 : k

// | |

// | ** |

// | ** |

// | ** ** |

// | ** ** |

// | **** |

// | ** ** |

// | ** ** |

{ 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 }, // 108 : l

// | |

// | ** |
// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x6B }, // 109 : m

// | |

// | |

// | |

// | ** ** |

// | *** *** |

// | ******* |

// | ** * ** |

// | ** * ** |

{ 0x00, 0x00, 0x00, 0x7C, 0x7E, 0x66, 0x66, 0x66 }, // 110 : n

// | |

// | |

// | |

// | ***** |

// | ****** |
// | ** ** |

// | ** ** |

// | ** ** |

{ 0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C }, // 111 : o

// | |

// | |

// | |

// | **** |

// | ** ** |

// | ** ** |

// | ** ** |

// | **** |

{ 0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60 }, // 112 : p

// | |

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ***** |

// | ** |

// | ** |
{ 0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x3C, 0x0D, 0x0F }, // 113 : q

// | |

// | |

// | **** |

// | ** ** |

// | ** ** |

// | **** |

// | ** * |

// | **** |

{ 0x00, 0x00, 0x00, 0x7C, 0x66, 0x66, 0x60, 0x60 }, // 114 : r

// | |

// | |

// | |

// | ***** |

// | ** ** |

// | ** ** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x00, 0x3E, 0x40, 0x3C, 0x02, 0x7C }, // 115 : s

// | |
// | |

// | |

// | ***** |

// | * |

// | **** |

// | * |

// | ***** |

{ 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18 }, // 116 : t

// | |

// | |

// | ** |

// | ** |

// | ****** |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E }, // 117 : u

// | |

// | |

// | |

// | ** ** |
// | ** ** |

// | ** ** |

// | ** ** |

// | ***** |

{ 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x18 }, // 118 : v

// | |

// | |

// | |

// | |

// | ** ** |

// | ** ** |

// | **** |

// | ** |

{ 0x00, 0x00, 0x00, 0x63, 0x6B, 0x6B, 0x6B, 0x3E }, // 119 : w

// | |

// | |

// | |

// | ** ** |

// | ** * ** |

// | ** * ** |

// | ** * ** |
// | ***** |

{ 0x00, 0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66 }, // 120 : x

// | |

// | |

// | |

// | ** ** |

// | **** |

// | ** |

// | **** |

// | ** ** |

{ 0x00, 0x00, 0x00, 0x66, 0x66, 0x3E, 0x06, 0x3C }, // 121 : y

// | |

// | |

// | |

// | ** ** |

// | ** ** |

// | ***** |

// | ** |

// | **** |

{ 0x00, 0x00, 0x00, 0x3C, 0x0C, 0x18, 0x30, 0x3C }, // 122 : z


// | |

// | |

// | |

// | **** |

// | ** |

// | ** |

// | ** |

// | **** |

{ 0x00, 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0E }, // 123 : {

// | |

// | *** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | *** |

{ 0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18 }, // 124 : |

// | |

// | ** |

// | ** |
// | ** |

// | |

// | ** |

// | ** |

// | ** |

{ 0x00, 0x70, 0x18, 0x18, 0x0C, 0x18, 0x18, 0x70 }, // 125 : }

// | |

// | *** |

// | ** |

// | ** |

// | ** |

// | ** |

// | ** |

// | *** |

{ 0x00, 0x00, 0x00, 0x3A, 0x6C, 0x00, 0x00, 0x00 }, // 126 : ~

// | |

// | |

// | |

// | *** * |

// | ** ** |

// | |
// | |

// | |

{ 0x00, 0x08, 0x1C, 0x36, 0x63, 0x41, 0x41, 0x7F } // 127 :

// | |

// | * |

// | *** |

// | ** ** |

// | ** ** |

// | * *|

// | * *|

// | ******* |

};

// Define display string here

const int charNum = 15;

char string[charNum] = {'A','R','D','U','I','N','O',' ','R','U','L','E','S','!',' '};

void effect_text(int delayt){

fill(0x00);

for (int ltr = 0; ltr < charNum; ltr++){// For each letter in string array
for(int dist = 0; dist < 8; dist++) { //bring letter forward

fill(0x00);//blank last row

int rev = 0;

for (int rw = 7; rw >= 0; rw--) {//copy rows

cube[rev][dist] = bitswap(font_data[string[ltr]][rw]);

rev++;

delay_ms(delayt);

unsigned char bitswap (unsigned char x)//Reverses a byte (so letters


aren't backwards);

{ byte result;

asm("mov __tmp_reg__, %[in] \n\t"

"lsl __tmp_reg__ \n\t" /* shift out high bit to carry */

"ror %[out] \n\t" /* rotate carry __tmp_reg__to low bit (eventually)


*/

"lsl __tmp_reg__ \n\t" /* 2 */

"ror %[out] \n\t"

"lsl __tmp_reg__ \n\t" /* 3 */

"ror %[out] \n\t"


"lsl __tmp_reg__ \n\t" /* 4 */

"ror %[out] \n\t"

"lsl __tmp_reg__ \n\t" /* 5 */

"ror %[out] \n\t"

"lsl __tmp_reg__ \n\t" /* 6 */

"ror %[out] \n\t"

"lsl __tmp_reg__ \n\t" /* 7 */

"ror %[out] \n\t"

"lsl __tmp_reg__ \n\t" /* 8 */

"ror %[out] \n\t"

: [out] "=r" (result) : [in] "r" (x));

return(result);

//
===========================================================
===============================

// Effect functions

//
===========================================================
===============================

void effect_box_wamp(int delayt)


{

for(int k = 0; k < 3; k++){

for(int i = 0; i < 4; i++){

fill(0x00);

box_filled(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

delay_ms(delayt);

for(int i = 3; i >= 0; i--){

fill(0x00);

box_filled(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

delay_ms(delayt);

for(int k = 0; k < 3; k++){

for(int i = 0; i < 4; i++){

fill(0x00);

box_walls(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

delay_ms(delayt);

for(int i = 3; i >= 0; i--){

fill(0x00);

box_walls(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
delay_ms(delayt);

for(int k = 0; k < 3; k++){

for(int i = 0; i < 4; i++){

fill(0x00);

box_wireframe(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

delay_ms(delayt);

for(int i = 3; i >= 0; i--){

fill(0x00);

box_wireframe(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);

delay_ms(delayt);

void draw_positions_axis (char axis, unsigned char positions[64], int


invert)

int x, y, p;

fill(0x00);
for (x=0; x<8; x++)

for (y=0; y<8; y++)

if (invert)

p = (7-positions[(x*8)+y]);

} else

p = positions[(x*8)+y];

if (axis == AXIS_Z)

setvoxel(x,y,p);

if (axis == AXIS_Y)

setvoxel(x,p,y);

if (axis == AXIS_X)

setvoxel(p,y,x);

}
}

void effect_boxside_randsend_parallel (char axis, int origin, int delayt,


int mode)

int i;

int done;

unsigned char cubepos[64];

unsigned char pos[64];

int notdone = 1;

int notdone2 = 1;

int sent = 0;

for (i=0;i<64;i++)

pos[i] = 0;

while (notdone)

if (mode == 1)

{
notdone2 = 1;

while (notdone2 && sent<64)

i = rand()%64;

if (pos[i] == 0)

sent++;

pos[i] += 1;

notdone2 = 0;

} else if (mode == 2)

if (sent<64)

pos[sent] += 1;

sent++;

done = 0;

for (i=0;i<64;i++)

{
if (pos[i] > 0 && pos[i] <7)

pos[i] += 1;

if (pos[i] == 7)

done++;

if (done == 64)

notdone = 0;

for (i=0;i<64;i++)

if (origin == 0)

cubepos[i] = pos[i];

} else

cubepos[i] = (7-pos[i]);

}
delay_ms(delayt);

draw_positions_axis(axis,cubepos,0);

void effect_rain (int iterations)

int i, ii;

int rnd_x;

int rnd_y;

int rnd_num;

for (ii=0;ii<iterations;ii++)

rnd_num = rand()%4;

for (i=0; i < rnd_num;i++)

rnd_x = rand()%8;
rnd_y = rand()%8;

setvoxel(rnd_x,rnd_y,7);

delay_ms(1000);

shift(AXIS_Z,-1);

// Set or clear exactly 512 voxels in a random order.

void effect_random_filler (int delayt, int state)

int x,y,z;

int loop = 0;

if (state == 1)

fill(0x00);

} else

fill(0xff);

}
while (loop<511)

x = rand()%8;

y = rand()%8;

z = rand()%8;

if ((state == 0 && getvoxel(x,y,z) == 0x01) || (state == 1 &&


getvoxel(x,y,z) == 0x00))

altervoxel(x,y,z,state);

delay_ms(delayt);

loop++;

void effect_blinky2()

int i,r;

fill(0x00);

for (r=0;r<2;r++)
{

i = 750;

while (i>0)

fill(0x00);

delay_ms(i);

fill(0xff);

delay_ms(100);

i = i - (15+(1000/(i/10)));

delay_ms(1000);

i = 750;

while (i>0)

fill(0x00);

delay_ms(751-i);

fill(0xff);

delay_ms(100);
i = i - (15+(1000/(i/10)));

// Draw a plane on one axis and send it back and forth once.

void effect_planboing (int plane, int speedd)

int i;

for (i=0;i<8;i++)

fill(0x00);

setplane(plane, i);

delay_ms(speedd);

for (i=7;i>=0;i--)

fill(0x00);

setplane(plane,i);

delay_ms(speedd);
}

//
===========================================================
===============================

// Draw functions

//
===========================================================
===============================

// Set a single voxel to ON

void setvoxel(int x, int y, int z)

if (inrange(x,y,z))

cube[z][y] |= (1 << x);

// Set a single voxel to ON

void clrvoxel(int x, int y, int z)

{
if (inrange(x,y,z))

cube[z][y] &= ~(1 << x);

// This function validates that we are drawing inside the cube.

unsigned char inrange(int x, int y, int z)

if (x >= 0 && x < 8 && y >= 0 && y < 8 && z >= 0 && z < 8)

return 0x01;

} else

// One of the coordinates was outside the cube.

return 0x00;

// Get the current status of a voxel

unsigned char getvoxel(int x, int y, int z)

if (inrange(x,y,z))
{

if (cube[z][y] & (1 << x))

return 0x01;

} else

return 0x00;

} else

return 0x00;

// In some effect we want to just take bool and write it to a voxel

// this function calls the apropriate voxel manipulation function.

void altervoxel(int x, int y, int z, int state)

if (state == 1)

setvoxel(x,y,z);

} else

{
clrvoxel(x,y,z);

// Flip the state of a voxel.

// If the voxel is 1, its turned into a 0, and vice versa.

void flpvoxel(int x, int y, int z)

if (inrange(x, y, z))

cube[z][y] ^= (1 << x);

// Makes sure x1 is alwas smaller than x2

// This is usefull for functions that uses for loops,

// to avoid infinite loops

void argorder(int ix1, int ix2, int *ox1, int *ox2)

if (ix1>ix2)

int tmp;

tmp = ix1;

ix1= ix2;

ix2 = tmp;
}

*ox1 = ix1;

*ox2 = ix2;

// Sets all voxels along a X/Y plane at a given point

// on axis Z

void setplane_z (int z)

int i;

if (z>=0 && z<8)

for (i=0;i<8;i++)

cube[z][i] = 0xff;

// Clears voxels in the same manner as above

void clrplane_z (int z)

int i;

if (z>=0 && z<8)

{
for (i=0;i<8;i++)

cube[z][i] = 0x00;

void setplane_x (int x)

int z;

int y;

if (x>=0 && x<8)

for (z=0;z<8;z++)

for (y=0;y<8;y++)

cube[z][y] |= (1 << x);

void clrplane_x (int x)

{
int z;

int y;

if (x>=0 && x<8)

for (z=0;z<8;z++)

for (y=0;y<8;y++)

cube[z][y] &= ~(1 << x);

void setplane_y (int y)

int z;

if (y>=0 && y<8)

for (z=0;z<8;z++)

cube[z][y] = 0xff;

}
void clrplane_y (int y)

int z;

if (y>=0 && y<8)

for (z=0;z<8;z++)

cube[z][y] = 0x00;

void setplane (char axis, unsigned char i)

switch (axis)

case AXIS_X:

setplane_x(i);

break;

case AXIS_Y:

setplane_y(i);

break;
case AXIS_Z:

setplane_z(i);

break;

void clrplane (char axis, unsigned char i)

switch (axis)

case AXIS_X:

clrplane_x(i);

break;

case AXIS_Y:

clrplane_y(i);

break;

case AXIS_Z:

clrplane_z(i);

break;

}
// Fill a value into all 64 byts of the cube buffer

// Mostly used for clearing. fill(0x00)

// or setting all on. fill(0xff)

void fill (unsigned char pattern)

int z;

int y;

for (z=0;z<8;z++)

for (y=0;y<8;y++)

cube[z][y] = pattern;

// Draw a box with all walls drawn and all voxels inside set

void box_filled(int x1, int y1, int z1, int x2, int y2, int z2)

int iy;
int iz;

argorder(x1, x2, &x1, &x2);

argorder(y1, y2, &y1, &y2);

argorder(z1, z2, &z1, &z2);

for (iz=z1;iz<=z2;iz++)

for (iy=y1;iy<=y2;iy++)

cube[iz][iy] |= byteline(x1,x2);

// Darw a hollow box with side walls.

void box_walls(int x1, int y1, int z1, int x2, int y2, int z2)

int iy;

int iz;

argorder(x1, x2, &x1, &x2);


argorder(y1, y2, &y1, &y2);

argorder(z1, z2, &z1, &z2);

for (iz=z1;iz<=z2;iz++)

for (iy=y1;iy<=y2;iy++)

if (iy == y1 || iy == y2 || iz == z1 || iz == z2)

cube[iz][iy] = byteline(x1,x2);

} else

cube[iz][iy] |= ((0x01 << x1) | (0x01 << x2));

// Draw a wireframe box. This only draws the corners and edges,

// no walls.

void box_wireframe(int x1, int y1, int z1, int x2, int y2, int z2)

{
int iy;

int iz;

argorder(x1, x2, &x1, &x2);

argorder(y1, y2, &y1, &y2);

argorder(z1, z2, &z1, &z2);

// Lines along X axis

cube[z1][y1] = byteline(x1,x2);

cube[z1][y2] = byteline(x1,x2);

cube[z2][y1] = byteline(x1,x2);

cube[z2][y2] = byteline(x1,x2);

// Lines along Y axis

for (iy=y1;iy<=y2;iy++)

setvoxel(x1,iy,z1);

setvoxel(x1,iy,z2);

setvoxel(x2,iy,z1);

setvoxel(x2,iy,z2);

// Lines along Z axis


for (iz=z1;iz<=z2;iz++)

setvoxel(x1,y1,iz);

setvoxel(x1,y2,iz);

setvoxel(x2,y1,iz);

setvoxel(x2,y2,iz);

// Returns a byte with a row of 1's drawn in it.

// byteline(2,5) gives 0b00111100

char byteline (int start, int end)

return ((0xff<<start) & ~(0xff<<(end+1)));

// Flips a byte 180 degrees.

// MSB becomes LSB, LSB becomes MSB.

char flipbyte (char byte)

char flop = 0x00;


flop = (flop & 0b11111110) | (0b00000001 & (byte >> 7));

flop = (flop & 0b11111101) | (0b00000010 & (byte >> 5));

flop = (flop & 0b11111011) | (0b00000100 & (byte >> 3));

flop = (flop & 0b11110111) | (0b00001000 & (byte >> 1));

flop = (flop & 0b11101111) | (0b00010000 & (byte << 1));

flop = (flop & 0b11011111) | (0b00100000 & (byte << 3));

flop = (flop & 0b10111111) | (0b01000000 & (byte << 5));

flop = (flop & 0b01111111) | (0b10000000 & (byte << 7));

return flop;

// Draw a line between any coordinates in 3d space.

// Uses integer values for input, so dont expect smooth animations.

void line(int x1, int y1, int z1, int x2, int y2, int z2)

float xy; // how many voxels do we move on the y axis for each
step on the x axis

float xz; // how many voxels do we move on the y axis for each
step on the x axis

unsigned char x,y,z;

unsigned char lasty,lastz;

// We always want to draw the line from x=0 to x=7.

// If x1 is bigget than x2, we need to flip all the values.


if (x1>x2)

int tmp;

tmp = x2; x2 = x1; x1 = tmp;

tmp = y2; y2 = y1; y1 = tmp;

tmp = z2; z2 = z1; z1 = tmp;

if (y1>y2)

xy = (float)(y1-y2)/(float)(x2-x1);

lasty = y2;

} else

xy = (float)(y2-y1)/(float)(x2-x1);

lasty = y1;

if (z1>z2)

xz = (float)(z1-z2)/(float)(x2-x1);

lastz = z2;
} else

xz = (float)(z2-z1)/(float)(x2-x1);

lastz = z1;

// For each step of x, y increments by:

for (x = x1; x<=x2;x++)

y = (xy*(x-x1))+y1;

z = (xz*(x-x1))+z1;

setvoxel(x,y,z);

// Delay loop.

// This is not calibrated to milliseconds,

// but we had allready made to many effects using this

// calibration when we figured it might be a good idea

// to calibrate it.
void delay_ms(uint16_t x)

uint8_t y, z;

for ( ; x > 0 ; x--){

for ( y = 0 ; y < 90 ; y++){

for ( z = 0 ; z < 6 ; z++){

asm volatile ("nop");

// Shift the entire contents of the cube along an axis

// This is great for effects where you want to draw something

// on one side of the cube and have it flow towards the other

// side. Like rain flowing down the Z axiz.

void shift (char axis, int direction)

int i, x ,y;

int ii, iii;

int state;
for (i = 0; i < 8; i++)

if (direction == -1)

ii = i;

} else

ii = (7-i);

for (x = 0; x < 8; x++)

for (y = 0; y < 8; y++)

if (direction == -1)

iii = ii+1;

} else

iii = ii-1;

}
if (axis == AXIS_Z)

state = getvoxel(x,y,iii);

altervoxel(x,y,ii,state);

if (axis == AXIS_Y)

state = getvoxel(x,iii,y);

altervoxel(x,ii,y,state);

if (axis == AXIS_X)

state = getvoxel(iii,y,x);

altervoxel(ii,y,x,state);

if (direction == -1)
{

i = 7;

} else

i = 0;

for (x = 0; x < 8; x++)

for (y = 0; y < 8; y++)

if (axis == AXIS_Z)

clrvoxel(x,y,i);

if (axis == AXIS_Y)

clrvoxel(x,i,y);

if (axis == AXIS_X)

clrvoxel(i,y,x);

Hay un archivo 8x8x8_led_cube_pattern


Arduino y Frambuesa Pi - Hablando sobre UART serie
Cules son los Pi frambuesa y Arduino? - Saltar este bit si se sabe que
El Arduino es un pequeo gran tablero, ofreciendo un buen montn de entrada y salida de uso
general (GPIO) estos son pasadores se puede programar para ser "Alto" (normalmente + 5V) o "baja"
(0 V). Los que se utilizan para el turno de el o control LED, motores y cualquier otra cosa electrnica
en el "mundo real".

Tiene un microcontrolador ATMega que funciona a 16 MHz y ejecuta el cdigo que escriba (y
compilar) del oso de metal ', es decir, el procesador comienza al principio de su cdigo y se ejecuta a
travs de l.

La Frambuesa Pi es un 'incrustado placa ARM Linux' - bsicamente una computadora pequea (del
tamao de una tarjeta de crdito)! Tiene un procesador de 700 MHz ARM y HDMI (para la conexin a
una televisin de alta definicin) y USB. Al ser mucho ms potente, de computacin inteligente, que
el Arduino se ejecuta un sistema operativo completo que se ejecuta el programa en, al igual que un
PC de escritorio.

Ambos son muy barato, el Arduino es alrededor de 16 para un 'clon' en eBay - si se obtiene un
modelo con el microcontrolador extrable que se puede sustituir por alrededor de 4 si lo
matas! Aunque la ma no tiene eso y no he muerto todava!

La Raspberry Pi cuesta alrededor de 25 y es realmente genial! Tiene GPIO como el ardiuno pero
que funcione a 3,3 V en lugar de 5V y son bastante delicada, las personas se les advierte
constantemente sobre los riesgos de matar a la Frambuesa Pi si consiguen 5V.

As que parece que ambos tienen sus pros y contras. Sera muy bueno si pudieran hablar!

Por eso les dieron a "hablar"!


Ahora, hice esto en mente con la obtencin de la Frambuesa Pi a algunos patrones se muestra en mi
cubo de 8x8x8 LED - ver blogs anteriores. El 3c3 (eso es lo que escribimos 3.3v) GPIO de la
frambuesa pi no era suficiente para alimentar las entradas 5v de los circuitos integrados utilizados en
el cubo de LED. Podra haber acaba de reemplazar los circuitos integrados utilizados por el cubo,
pero no pudo encontrar los que caba la factura - que necesitaba para reemplazar el 74 HC 595 con
la alta velocidad, baja tensin de la versin 74 HCT 595, pero necesitaba un tablero compatibles
(DIP) uno bastante barato en el Reino Unido - Si encuentra una fuente por favor dejar un
comentario!usted puede utilizar el USB para hablar, pero el R-Pi slo tiene 2 puertos USB y yo no
quera que sean utilizados por el Arduino cuando pueden hablar a un nivel mucho ms bajo. El puerto
USB es Arduino convertidor de USB a serie y utiliza los mismos dos pasadores como UART hace de
todos modos!

Jugando muy bien!

usando UART
UART significa Univeral asncrono universal del receptor / transmisor. Es una interfaz serie y es
bastante simple para ponerse en marcha. Slo tiene que ser consciente de algunas cosas:

El UART en el Raspberry Pi es 3v3 y el de la Arduino es 5v. No es una buena idea para conectar
juntos. He utilizado elSparkfun nivel de la lgica del convertidor , bsicamente se conecta la clavija
HV lado alto de 5V del Arduino, obviamente GND a GND A continuacin, la parte alta TXO clavijas al
pin RX (pin 0) y el RXI al pin TX (pin 1) . El lado de baja (LV) para 3v3 la frambuesa del Pi (pin 1 de la
cabecera GPIO 26 pines) GND a GND (pin 6), el pasador de TXI al TX (pin 8) y RXO a la RX (pin
10). (puede que haya llegado el lado equivocado Arduino, como he desenchufado ahora, de ser as
intentar cambiar los pines 0 y 1) est bien , ahora lo que necesita algo de cdigo, el cdigo de la
Arduino es tan fcil como esto:

void setup ()
{
Serial.begin (9600);
}
void loop ()
{
// si hay alguna disposicin en serie, lo ley:
while (Serial.available ()> 0)
// Buscar la siguiente entero vlido en la serie de entrada int
value = Serial.parseInt (); // buscar la nueva lnea. Ese es el final
de la frase: si (Serial.read () == '\ n') { SHIFTOUT (datos,
reloj, MSBFIRST, valor);

} } } Ahora, eso slo se necesita el nmero de enviar a l y lo desplaza a su registro de


desplazamiento, Que haba necesidad de reemplazar los datos y reloj con el nmero de sus
datos de registros de desplazamiento y botones de reloj. Si est utilizando registros de retencin
(como el 74HC595) que necesita para sacar el pasador de alta y baja despus de eso. El cdigo PI
Rasperry es diferente. Es necesario utilizar el dispositivo serie como un archivo y escribir en
l. Aunque en primer lugar, que puede ser mejor para comprobar nada est utilizando la UART que
est representado en Linux como / dev / ttyAMA0. La imagen de Debian lo usa para el arranque y lo
que es peor, para el acceso de terminal. Eliminar las lneas de abajo (cualquier referencia a ttyAMA0
en realidad) de /boot/cmdline.txt

consola = ttyAMA0,115200 kgdboc = ttyAMA0,115200


Tambin en comentario (poner un # delante de) la siguiente lnea de / etc / inittab
2: 23: respawn: / sbin / getty -L ttyAMA0 115200 VT100
Esas instrucciones son de Blog de sabidura Calvo Ahora bien, para conseguir este trabajo que
necesitaba para establecer la velocidad de serie para que coincida con el cdigo de Arduino (que se
poda establecer el Arduino para que coincida con la del R-Pi, pero yo soy mucho ms feliz con ellos
a 9600 baudios, especialmente en un circuito!tambin el control de flujo de hardware con
discapacidad (creo que tiene algo que ver con no ser un puerto UART completa) y ponerlo a 8N1
modo, ms sobre que se puede leer aqu . se puede ver la terminado cdigo
aqu:http://pastebin.com/4auyRMxY compilar con (fuente con el nombre de archivo del cdigo fuente,
destino, con lo que sea):
gcc -o destination.o source.c
A continuacin, puede ejecutarlo con (en sustitucin de destino con lo que pones en 255 y con el
nmero para enviar):
./destination.o 255
Publicado 20 de de junio de 2012 por Liam Jackson

1
Ver comentarios

1.

Alexander Faichney18 de de marzo de 2013 a 22:02

Estoy haciendo un cubo de 8x8x8 LED y slo quiero usar la frambuesa pi. Es posible utilizar el mismo
conjunto hasta que usted tiene para que funcione en el pi frambuesa? Sera capaz de ayudarme con esto
y que me haga saber lo que tendra que cambiar, en todo caso, en el cdigo que usted tiene para que
funcione. Gracias. mi correo es: the_great_man@hotmail.co.uk
Respuesta

Você também pode gostar