HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Useful guides, libraries, and example sketches to support our Arduino based products.
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by admin » Tue Mar 15, 2016 2:12 pm

[IMAGE TBA]



Arduino library to control the Hobby Components 8x8x8 LED cube kit (HCKITS0050). If you are interested in building an 8x8x8 LED cube the please take a look at our very own and easy to build (through-hold components) 8x8x8 LED cube kits. They available in the following colours:

Blue: HCKITS0050
Green: TBA
Red: TBA
White TBA



This library will handle the automatic refreshing of the cube and provides a set of library functions for controlling the LED on the cube, and displaying text and graphic animations. Additionally the library also comes with a set of predefined patters and that can be played back to the cube with just one command.

You will need to download (please log in to download the library) and unzip this library to the Arduino development environments library area.

On Windows:
My Documents\Arduino\libraries\

On Mac:
Documents/Arduino/libraries/

Linux:
Usually found within the users home area under /Arduino/libraries/



Using the HC8x8x8Cube library

To use the library just include the HC8x8x8Cube.h header file in your own sketch:

Code: Select all

#include "HC8x8x8Cube.h"


To initialise the library place the following line in the Setup() loop at the top of the sketch:

Code: Select all

CubeInit();
One the library has been initiliased you can control the states of the LEDs on the cube with the following library functions:

Code: Select all

CubeClearBuffer();
Clears all LED data in the matrix buffer (turns off all LEDs).


Code: Select all

Base_LED(State);
Used to set the state of the 10mm base LEDs where:
State is the state the LEDs will be set to. Valid values are
ON (All 4 LED are turned on)
OFF (All 4 LEDs are turned off)

Code: Select all

SetVoxel(x, y, z);
Sets (turns on) the state of a single LED (Voxel) where:
x is the x coordinate of the LED to set. Valid values are 0 to 7
y is the y coordinate of the LED to set. Valid values are 0 to 7
z is the z coordinate of the LED to set. Valid values are 0 to 7


Code: Select all

SetVoxel(x, y, z, View, Direction);
Sets (turns on) the state of a single LED (Voxel) where:
x is the x coordinate of the LED to set. Valid values are 0 to 7

y is the y coordinate of the LED to set. Valid values are 0 to 7

z is the z coordinate of the LED to set. Valid values are 0 to 7

View is the perspective from which the x, y, and z coordiantes are referenced from. Valid values are
FRONT (coordiantes are referenced from the front of the cube)
BACK (coordiantes are referenced from the back of the cube)
LEFT (coordiantes are referenced from the left side of the cube)
RIGHT (coordiantes are referenced from the right side of the cube)
TOP (coordiantes are referenced from the top of the cube)
BOTTOM (coordiantes are referenced from the bottom of the cube)

Direction specifies side of the cube coordates are referenced from. Valid values are
FORWARD (Coordiantes are referenced from the bottom left corner)
REVERSE (Coordiantes are referenced from the bottom right corner


Code: Select all

ClearVoxel(x, y, z);
Clears (turns off) the state of a single LED (Voxel) where:
x is the x coordinate of the LED to clear. Valid values are 0 to 7
y is the y coordinate of the LED to clear. Valid values are 0 to 7
z is the z coordinate of the LED to set. Valid values are 0 to 7


Code: Select all

ClearVoxel(x, y, z, View, Direction);
Clears (turns off) the state of a single LED (Voxel) where:
x is the x coordinate of the LED to clear. Valid values are 0 to 7

y is the y coordinate of the LED to clear. Valid values are 0 to 7

z is the z coordinate of the LED to set. Valid values are 0 to 7

View is the perspective from which the x, y, and z coordiantes are referenced from. Valid values are
FRONT (coordiantes are referenced from the front of the cube)
BACK (coordiantes are referenced from the back of the cube)
LEFT (coordiantes are referenced from the left side of the cube)
RIGHT (coordiantes are referenced from the right side of the cube)
TOP (coordiantes are referenced from the top of the cube)
BOTTOM (coordiantes are referenced from the bottom of the cube)

Direction specifies side of the cube coordates are referenced from. Valid values are
FORWARD (Coordiantes are referenced from the bottom left corner)
REVERSE (Coordiantes are referenced from the bottom right corner)


Code: Select all

State = GetVoxel(x, y, z);
Gets the current state of a single LED (Voxel) where:
x is the x coordinate of the LED. Valid values are 0 to 7
y is the y coordinate of the LED. Valid values are 0 to 7
z is the z coordinate of the LED. Valid values are 0 to 7


Returns the current state of the LED where
true = LED at coordinate x,y,z is currently ON
false = LED at coordinate x, y, z is currently OFF

Code: Select all

boolean GetVoxel(x, y, z, View, Direction)
Gets the current state of a single LED (Voxel) where:
x is the x coordinate of the LED. Valid values are 0 to 7
y is the y coordinate of the LED. Valid values are 0 to 7
z is the z coordinate of the LED. Valid values are 0 to 7

View is the perspective from which the x, y, and z coordiantes are referenced from. Valid values are
FRONT (coordiantes are referenced from the front of the cube)
BACK (coordiantes are referenced from the back of the cube)
LEFT (coordiantes are referenced from the left side of the cube)
RIGHT (coordiantes are referenced from the right side of the cube)
TOP (coordiantes are referenced from the top of the cube)
BOTTOM (coordiantes are referenced from the bottom of the cube)

Direction specifies side of the cube coordates are referenced from. Valid values are
FORWARD (Coordiantes are referenced from the bottom left corner)
REVERSE (Coordiantes are referenced from the bottom right corner)

Returns the current state of the LED where
true = LED at coordinate x,y,z is currently ON
false = LED at coordinate x, y, z is currently OFF


Code: Select all

Shift_Cube(Axis, Direction);
Shifts the entire grid of LEDs in one direction where
Axis is the x, y, or z axis to shift the LEDs in. Valid values are
X_Axis (Shifts the LEDs one place in the x axis)
Y_Axis (Shifts the LEDs one place in the y axis)
Z_Axis (Shifts the LEDs one place in the z axis)

Direction is the direction in which to shift the LEDs. Valid values are
FORWARD (Shifts the LEDs by one position in the forward direction)
REVERSE (Shifts the LEDs by one position in the reverse direction)

Code: Select all

printString(TextString[],  Offset, Axis,  Layer, Direction);
Prints a string of alphanumeric text to the cube on a specified axis and layer where:
TextString[] is a string array containing the text to be displayed.

Offset is the column position on the cube from where to start displaying the text from

Axis is which axis (x, y, or z) to display the text on. Valid values are
X_Axis (Displays the text on the vertical x axis)
Y_Axis (Displays the text on the vertical y axis)
Z_Axis (Displays the text on the horizontal z axis)

Layer is the on which to display the text. Valid values are from 0 to 7

Direction specifies in which direction to print the text to the cube. Valid values are
FORWARD (Prints the text in the forward direction. I.e. left to right)
REVERSE (Prints the text in the reverse direction. I.e. right to left)

Code: Select all

printWrap(TextString[], Offset, IncludeBack);
Uses the PrintString function to wrap a string of text around the outside of the cube where:
TextString[] is a string array containing the text to be displayed

Offset is the column position on the cube from where to start displaying the text from

IncludeBack specifies whether to include the rear side of the cube when wrapping the text around it. Valid values are
true (include the back when wrapping the text)
false (do not include the back when wrapping the text)

Code: Select all

Scroll_Text(TextString[], Mode, Speed);
Automatically scrolls a string of text in one of 26 ways. Where:
TextString[] is a string array containing the text to be displayed.

Mode specifies how the text will be scrolled. Valid values are:
Scroll_X_Layer0 (Scrolls the text in the x axis on layer 0)
Scroll_X_Layer1 (Scrolls the text in the x axis on layer 1)
Scroll_X_Layer2 (Scrolls the text in the x axis on layer 2)
Scroll_X_Layer3 (Scrolls the text in the x axis on layer 3)
Scroll_X_Layer4 (Scrolls the text in the x axis on layer 4)
Scroll_X_Layer5 (Scrolls the text in the x axis on layer 5)
Scroll_X_Layer6 (Scrolls the text in the x axis on layer 6)
Scroll_X_Layer7 (Scrolls the text in the x axis on layer 7)
Scroll_Y_Layer0 (Scrolls the text in the y axis on layer 0)
Scroll_Y_Layer1 (Scrolls the text in the y axis on layer 1)
Scroll_Y_Layer2 (Scrolls the text in the y axis on layer 2)
Scroll_Y_Layer3 (Scrolls the text in the y axis on layer 3)
Scroll_Y_Layer4 (Scrolls the text in the y axis on layer 4)
Scroll_Y_Layer5 (Scrolls the text in the y axis on layer 5)
Scroll_Y_Layer6 (Scrolls the text in the y axis on layer 6)
Scroll_Y_Layer7 (Scrolls the text in the y axis on layer 7)
Scroll_z_Layer0 (Scrolls the text in the z axis on layer 0)
Scroll_z_Layer1 (Scrolls the text in the z axis on layer 1)
Scroll_z_Layer2 (Scrolls the text in the z axis on layer 2)
Scroll_z_Layer3 (Scrolls the text in the z axis on layer 3)
Scroll_z_Layer4 (Scrolls the text in the z axis on layer 4)
Scroll_z_Layer5 (Scrolls the text in the z axis on layer 5)
Scroll_z_Layer6 (Scrolls the text in the z axis on layer 6)
Scroll_z_Layer7 (Scrolls the text in the z axis on layer 7)
Scroll_Wrap (Scrolls the text around the outside of the cube)
Scroll_Full_Wrap (Scrolls the text around the outside of the cube including the back of the cube)

Speed specifies how fast in millisecond steps to scroll the text. Valid values are 1ms to 1023ms per step.


Code: Select all

Cube(x1, y1, z1, x2,  y2, z2, Solid);
Used to display a 3D cube primitive where:
x1 is the x axis coordinate for the first corner of the cube.
y1 is the y axis coordinate for the first corner of the cube.
z1 is the z axis coordinate for the first corner of the cube.
x2 is the x axis coordinate for the opposite corner of the cube.
y2 is the y axis coordinate for the opposite corner of the cube.
z2 is the z axis coordinate for the opposite corner of the cube.
valid values for x1, y1, z1, x2, y2, z2 are from 0 to 7

Solid specifies whether the cube should be drawn solid (filled in) or wire frame

Code: Select all

Line(x1, y1, z1, x2, y2, z2);
Used to draw a single Voxel width line in 3D:
x1 is the x axis coordinate for the first end of the line.
y1 is the y axis coordinate for the first end of the line.
z1 is the z axis coordinate for the first end of the line.
x2 is the x axis coordinate for the opposite end of the line.
y2 is the y axis coordinate for the opposite end of the line.
z2 is the z axis coordinate for the opposite end of the line.
valid values for x1, y1, z1, x2, y2, z2 are from 0 to 7


Code: Select all

Bitmap(Bitmap[], Offset, Axis, Layer, Direction);
Displays an array containing a binary 8x8 bitmap image where:
Bitmap[] is a 1 dimensional array of 8 bytes containing the bitmap image to displayed. This must be stored in program memory and of type byte (const byte).

Offset is the column position on the cube from where to start displaying the bitmap from

Axis is which axis (x, y, or z) to display the bitmap on. Valid values are
X_Axis (Displays the bitmap on the vertical x axis)
Y_Axis (Displays the bitmap on the vertical y axis)
Z_Axis (Displays the bitmap on the horizontal z axis)

Layer is the on which to display the bitmap. Valid values are from 0 to 7

Direction specifies in which direction to print the bitmap to the cube. Valid values are
FORWARD (Prints the bitmap in the forward direction. I.e. left to right)
REVERSE (Prints the bitmap in the reverse direction. I.e. right to left)


Code: Select all

WrapBitmap(bitmap[], Offset, IncludeBack);
Uses the Bitmap() function to wrap a bitmap on the outside of the cube where:
Bitmap[] is a 1 dimensional array of 8 bytes containing the bitmap image to displayed. This must be stored in program memory and of type byte (const byte).

Offset is the column position on the cube from where to start displaying the bitmap from

IncludeBack specifies whether to include the rear side of the cube when wrapping the bitmap around it. Valid values are
true (include the back when wrapping the bitmap)
false (do not include the back when wrapping the bitmap)


Code: Select all

State = ModeButtonState();
Gets the current state of the mode button

Returns the current state where
MODE_NOT_PRESSED = The mode button has not been pressed
MODE_SHORT_PRESS = The mode button has been pressed for between 100 to 500ms
MODE_LONG_PRESS = The mode button has been pressed for longer than 1 second.

The mode state is not automatically cleared. Once you have read the state you must clear
it with the Clear_Mode_Button_State() function.


Code: Select all

Clear_Mode_Button_State();
Clears the current status (MODE_NOT_PRESSED) of the mode button.


Code: Select all

State = Mode_Repeat();
Checks if the mode button has been pressed for longer than 1 second and if so toggles the repeat mode flag

Returns a boolean value that will toggle state each time the mode button has been pressed for longer than 1 second

This function can be used in a loop to give the user the option of continually repeating a pattern.



Using the pre-defined patterns

The library also provides a set of pre-defined patterns what can be written to the cube with just one command. These patterns are also pre-programmed into ATMega328 device provided with the 8x8x8 cube kit. To use this patterns you will need to include the HC8x8x8_Cube_Patterns.h header file at the top of your sketch:

Code: Select all

#include "HC8x8x8_Cube_Patterns.h"

The following patterns are available:

Code: Select all

Pattern_Frame(Cycles, Speed);
Display a sweeping 8x8 grid of LEDs where:
Cycles is the number of repetitions. Valid values are from 1 to 254

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023


Code: Select all

Pattern_All_Flash(Cycles, Speed);
Flash all the LEDs where:
Cycles is the number of repetitions. Valid values are from 1 to 254

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023


Code: Select all

Pattern_Random_Slide(Speed, Axis, Direction)
Shifts an 8x8 grid of LEDs from one sides of the cube to the other by one
random LED at a time. Where:
Speed is the speed at which to move each LED in 1ms increments.

Axis is the x, y, or z axis to shift the LEDs in. Valid values are
X_Axis
Y_Axis
Z_Axis

Direction is the direction in which to animate the movement of the LEDs. Valid values are
FORWARD
REVERSE


Code: Select all

Pattern_Rain(Cycles,  Speed, Intensity, Direction);
Random rain effect pattern where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023

Intensity is how many 'drops' of rain to animate. Valid values are 1 to 254

Direction is the direction in which to animate the rain drops. Valid values are
FORWARD (Rain drops will move from the top layer to the bottom layer of the cube)
REVERSE (Rain drops will move from the bottom layer to the top layer of the cube)


Code: Select all

Pattern_StarField(Cycles,  Speed, Intensity, Direction);
Random star field pattern where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023

Intensity is how many 'stars' to animate. Valid values are 1 to 254

Direction is the direction in which to animate the movement of the stars. Valid values are
FORWARD (stars will move from the rear layer to the front layer of the cube)
REVERSE (stars will move from the front layer to the rear layer of the cube)


Code: Select all

Pattern_Blizzard(Cycles,  Speed, Intensity, Direction);
Random blizzard field pattern where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023

Intensity is how many 'snow flakes' to animate. Valid values are 1 to 254

Direction is the direction in which to animate the movement of the snow. Valid values are
FORWARD (snow will move from the right layer to the left layer of the cube)
REVERSE (stars will move from the left layer to the right layer of the cube)


Code: Select all

Pattern_Random_Fill(byte Speed);
Tuns on each LED in a random pattern until all LEDs are on. Where:
Speed is the speed at which to turn each LED on specified in 1ms increments. Valid values are from 1 to 254


Code: Select all

Pattern_Random_Clear(byte Speed);
Tuns off each LED in a random pattern until all LEDs are off. Where:
Speed is the speed at which to turn each LED off specified in 1ms increments. Valid values are from 1 to 254


Code: Select all

Pattern_Random_Clear(byte Speed);
Bounces a number of 4x4x4 cubes in 3 dimensions where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.

Objects is the number if 4x4x4 cubes to animate. valid values are from 1 to 254.


Code: Select all

Pattern_SineWave( Cycles, Speed);
Displays a scrolling sine wave on all layers where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_LineDance(Cycles, Speed);
Bounces a line within the cube in a 3d motion where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_PlasmaBall(Cycles, Speed);
Uses the line function to create a plasma ball effect where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_PM(Cycles, Speed);
Uses the bitmap function to play an animation around the outside edges of the cube where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_WireCube(Cycles, Speed);
Draws an expanding wire frame cube from one corner to another where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_CubeSlide(Cycles, Speed);
Slides an 8x8x8 cube from the right side to the left side where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_CubeSwap(Cycles, Speed);
Moves four 4x4x4 LED cubes in a pattern where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_CubeBounce(Cycles, Speed, Objects);
Bounces a number of 4x4x4 cubes in 3 dimensions where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.

Objects is the number if 4x4x4 cubes to animate. valid values are from 1 to 254.



Code: Select all

Pattern_TextWrap(Cycles, Speed);
Scrolls the text '8x8x8LEDCube' around the outside of the cube where:
Cycles is the number of repetitions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_Text3D(Cycles, Speed);
Scrolls the text '8x8x8LEDCube' through the middle 4 layers of the cube to create a 3D text effect where:
Cycles is the number of repititions. Valid values are from 1 to 1023

Speed is the speed at which to step though each frame of the animation in 1ms increments. Valid values are from 1 to 1023.


Code: Select all

Pattern_Countdown();
Scrolls the numbers 5 to 1 from the front of the cube to the back to create a countdown effect.



Image
  1. /* FILE:    HC8x8x8_Play_Patterns
  2.    DATE:    14/03/16
  3.    VERSION: 0.1
  4.    AUTHOR:  Andrew Davies
  5.  
  6. 14/03/16 version 0.1: Original version
  7.  
  8.  
  9. This is the default sketch that comes pre-programmed into the cube. It will
  10. sequence through each of the patterns available in the HC8x8_Cube_Patterns_library.
  11.  
  12. You may copy, alter and reuse this code in any way you like, but please leave
  13. reference to HobbyComponents.com in your comments if you redistribute this code.
  14. This software may not be used directly for the purpose of selling products that
  15. directly compete with Hobby Components Ltd's own range of products.
  16.  
  17. THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
  18. EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  19. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
  20. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
  21. INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
  22. REASON WHATSOEVER.
  23. */
  24.  
  25. /* Include the LED cube and patterns library */
  26. #include "HC8x8x8Cube.h"
  27. #include "HC8x8x8_Cube_Patterns.h"
  28.  
  29.  
  30. /* Set the animation speed for each pattern */
  31. #define SPEED 100
  32.  
  33.  
  34. void setup()
  35. {
  36.   /* Initialises the cube library */
  37.   CubeInit();
  38. }
  39.  
  40. /* Main loop */
  41. void loop()
  42. {
  43.   byte index1, index2;
  44.  
  45.   /* Play the start animation only when the cube is first turned on */
  46.   Scroll_Text("8x8x8LEDCubeDemo", Scroll_X_Layer0, SPEED / 2);
  47.   Pattern_Countdown();
  48.   Pattern_All_Flash(10, SPEED);
  49.  
  50.   /* Play the patterns in a continuous loop */
  51.   while(1)
  52.   {
  53.    
  54.     /* Display a sweeping 8x8 grid of LEDs */
  55.     do
  56.     {
  57.       Pattern_Frame(5, SPEED);
  58.     }while(Mode_Repeat());
  59.  
  60.     /* Random rain effect */
  61.     do
  62.     {
  63.       Pattern_Rain(100, SPEED, 20, FORWARD);
  64.     }while(Mode_Repeat());
  65.  
  66.     /* Random rain effect in reverse direction */
  67.     do
  68.     {
  69.       Pattern_Rain(100, SPEED, 20, REVERSE);
  70.     }while(Mode_Repeat());
  71.  
  72.     /* Random star field pattern */
  73.     do
  74.     {
  75.       Pattern_StarField(100, SPEED, 5, FORWARD);
  76.     }while(Mode_Repeat());
  77.  
  78.     /* Random star field pattern in reverse direction */
  79.     do
  80.     {
  81.       Pattern_StarField(100, SPEED, 5, REVERSE);
  82.     }while(Mode_Repeat());
  83.  
  84.     /* Random blizzard field pattern */
  85.     do
  86.     {
  87.       Pattern_Blizzard(100, SPEED, 5, FORWARD);
  88.     }while(Mode_Repeat());
  89.  
  90.     /* Random blizzard field pattern in reverse direction*/
  91.     do
  92.     {
  93.       Pattern_Blizzard(100, SPEED, 5, REVERSE);
  94.     }while(Mode_Repeat());
  95.     CubeClearBuffer();
  96.  
  97.     /* Scrolls the text '8x8x8LEDCube' through the middle 4 layers of the cube to create a 3D text effect */
  98.     do
  99.     {
  100.       Pattern_Text3D(1, SPEED);
  101.     }while(Mode_Repeat());
  102.     CubeClearBuffer();
  103.  
  104.     /* Randomly turn on then off all the LEDs */
  105.     do
  106.     {
  107.       for(index1 = 0; index1 < 3; index1++)
  108.       {
  109.       Pattern_Random_Fill(SPEED / 10);
  110.       Pattern_Random_Clear(SPEED / 10);
  111.       }
  112.     }while(Mode_Repeat());
  113.  
  114.  
  115.     /* Randomly bounce ten 4x4x4 cubes */
  116.     do
  117.     {  
  118.       Pattern_CubeBounce(1023, SPEED / 5, 10);
  119.     }while(Mode_Repeat());
  120.  
  121.  
  122.     /*  Displays a scrolling sine wave on all layers */
  123.     Pattern_SineWave(300, SPEED * 0.7);
  124.  
  125.     /* Bounces a line within the cube in a 3d motion */
  126.     Pattern_LineDance(500, SPEED / 2);
  127.  
  128.     /* Uses the line function to create a plasma ball */
  129.     Pattern_PlasmaBall(200, SPEED / 2);
  130.  
  131.     /* Uses the bitmap function to play an animation around the outside edges of the cube */
  132.     Pattern_PM(3, SPEED * 1.5 /*130*/);
  133.  
  134.     /* Draws an expanding wire frame cube from one corner to another */
  135.     Pattern_WireCube(5, SPEED / 2);
  136.  
  137.     /* Slides an 8x8x8 cube from the right side to the left side */
  138.     Pattern_CubeSlide(5, SPEED / 2);
  139.     CubeClearBuffer();
  140.  
  141.     /* Scrolls the text '8x8x8LEDCube' around the outside of the cube */
  142.     Pattern_TextWrap(1, SPEED);
  143.  
  144.     /* Moves four 4x4x4 LED cubes in a pattern */
  145.     Pattern_CubeSwap(5, SPEED);
  146.  
  147.     /* Bounces a single 4x4x4 cube in 3 dimensions */
  148.     Pattern_CubeBounce(1023, SPEED / 10 , 1);
  149.   }
  150. }


Image

The HC8x8x8Cube library (V0.2) can be downloaded here (please log in to download):
HC8x8x8Cube.zip
You do not have the required permissions to view the files attached to this post.

ILYBTodd
Posts: 44
Joined: Mon Nov 05, 2018 6:20 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by ILYBTodd » Wed Jan 06, 2021 10:32 pm

Andrew,

Do you know anything about what might be required to be done to the zip file to allow me to upload it to the Custom Library folder in create.Arduino.cc ?

https://forum.arduino.cc/index.php?topic=639807.0

Suggests a library.properties file in the root folder could fix the issue.

Todd

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by andrew » Thu Jan 07, 2021 10:11 am

Do you know anything about what might be required to be done to the zip file to allow me to upload it to the Custom Library folder in create.Arduino.cc ?

https://forum.arduino.cc/index.php?topic=639807.0

Suggests a library.properties file in the root folder could fix the issue.

That's correct, you need a library.properties properties file in the root folder of the library for it to upload into the Arduino web editor. I've attached one for the HC8x8x8Cube that should work. Just download it and save it to the root library folder which should be in you documents folder at this location:


\Arduino\libraries\HC8x8x8Cube\


library.properties
You do not have the required permissions to view the files attached to this post.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

OhBaby25431$
Posts: 1
Joined: Fri Jan 08, 2021 12:01 am

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by OhBaby25431$ » Fri Jan 08, 2021 12:28 am

Hi Andrew,
Well I wasn't sure if the file needed to be saved in the first level or in the level with the cpp and h files etc so I did save it in both and... it worked!

Uploaded to the cloud based Arduino IDE and allowed me to compile the sketch no problem. Now I can work on my pattern development from home, work, etc.

Thanks again for your help.

Todd

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by andrew » Fri Jan 08, 2021 9:55 am

That's great. Just for future reference it goes in the same level as .ccp and .h files but next time I push a new version of the library I'll make sure it's included.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

machasm
Posts: 1
Joined: Sun Jul 24, 2022 7:58 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by machasm » Tue Jul 26, 2022 7:10 pm

Hi Andrew,
I have built this cube and it has worked very well.
Not being much of a programmer myself, are you aware of anywhere that might have some more patterns for this cube that I might be able to download?
Thanks in advance.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by andrew » Wed Jul 27, 2022 2:00 pm

I’m afraid the only patterns we know of are the ones we’ve created ourselves which are all the ones included in the demo sketch. If you do end up wanting to have a go at doing your own pattern though, then just let me know. I’ll add a basic example for turning on/off LEDs or drawing a line etc to help give you an idea of what to do.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

David470
Posts: 5
Joined: Wed Aug 31, 2022 9:23 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by David470 » Wed Oct 19, 2022 8:40 pm

Hi, sorry to be a pain.... Is there any video on how to write a pattern, that would help to understand it? i can get the cube to light up specific LEDs. What i dont get is how to time it, so for example if i want certain LED to stay on for a second and then go off?

Thanks,
David

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by andrew » Thu Oct 20, 2022 8:14 am

Is there any video on how to write a pattern, that would help to understand it? i can get the cube to light up specific LEDs. What i dont get is how to time it, so for example if i want certain LED to stay on for a second and then go off?

I'm afraid there isn't a tutorial video because actually using the library commands falls under the domain of having a basic understanding of the C (C++) programming language.

For example, to blink an LED you could write a sketch that is effectively the standard Arduino 'blink' example but just with the digitalWrite() commands swapped out for the libraries SetVoxel() and ClearVoxel() commands like this....


  1. #include "HC8x8x8Cube.h"
  2.  
  3. void setup()
  4. {
  5.   CubeInit();
  6. }
  7.  
  8.  
  9. void loop()
  10. {
  11.   SetVoxel(0, 0, 0);
  12.   delay(1000);
  13.   ClearVoxel(0, 0, 0);
  14.   delay(1000);
  15. }


Here is an example using the C languages for() function and variables to make a single LED move across the x axis...
  1. #include "HC8x8x8Cube.h"
  2.  
  3. void setup()
  4. {
  5.   CubeInit();
  6. }
  7.  
  8.  
  9. void loop()
  10. {
  11.   for(byte i = 0; i < 8; i++)
  12.   {
  13.     SetVoxel(i, 0, 0);
  14.     delay(1000);
  15.     ClearVoxel(i, 0, 0);
  16.   }
  17. }
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

David470
Posts: 5
Joined: Wed Aug 31, 2022 9:23 pm

Re: HC8x8x8Cube library for H.C. 8x8x8 LED Cube Kit (HCKITS0050)

Post by David470 » Tue Oct 25, 2022 9:44 am

Thanks a lot for the tips. Ill try create sometnig.

Thanks,
David

Post Reply

Return to “Arduino”