This document provides detailed descriptions of all example sketches included with the Cubong library.
The library includes 10 example sketches demonstrating various features:
- TestTensore - Basic tensor system test
- Miss - Text display demonstration
- RiempiCubo - Random filling animation
- SfogliaLed - Individual LED scanning
- SfogliaPiani - Layer cycling
- SfogliaPiani_Vuoto - Empty layer cycling
- SfogliaPiani_input - Interactive layer cycling
- StampaTensore - Tensor pattern demonstration
- StampaTensore_Piani - Layer-by-layer pattern building
- LampeggiaCubo_Input - Interactive blinking
File: examples/TestTensore/TestTensore.ino
This example demonstrates the basic tensor system functionality. It tests the tensor-to-buffer conversion and display functions.
- Tensor initialization
- Adding LEDs to the tensor using
add() - Converting tensor to buffer
- Displaying patterns on the cube
- Standard Cubong setup with 3 control pins (data=7, latch=6, clock=5)
test.testTensore();The testTensore() method cycles through different patterns, displaying them for 5 seconds each.
File: examples/Miss/Miss.ino
Displays the word "MISS" on the cube with variable positioning controlled by an analog input (potentiometer).
- Text display functions (
letteraM(),letteraI(),letteraS()) - Analog input reading for interactive control
- Letter positioning in 3D space
- Standard Cubong setup (data=7, latch=6, clock=5)
- Potentiometer connected to analog pin A0
- Reads analog input value (0-1023)
- Maps input to position (0-4)
- Displays each letter 20 times before moving to the next
- Repeats sequence: M → I → S → S
Turn the potentiometer to change the position of the letters in the cube.
File: examples/RiempiCubo/RiempiCubo.ino
Creates an animation that fills the cube randomly, one LED at a time, creating a "filling" effect.
- Random LED selection
- Sequential LED activation
- The
riempiCubo()function
- Standard Cubong setup with 4 control pins (data=7, latch=6, clock=5, enable=4)
- Randomly selects a column (x, y position)
- Fills that column from bottom to top (z=0 to z=4)
- Adds a 15ms delay between each LED for visual effect
- Repeats indefinitely
File: examples/SfogliaLed/SfogliaLed.ino
Scans through all 125 LEDs in the cube sequentially, creating a scanning effect.
- Triple nested loop for 3D scanning
- Individual LED control using
led() - Sequential activation pattern
- Standard Cubong setup
The sketch scans in this order:
- Through all layers (z: 0→4)
- For each layer, through all rows (i: 0→4)
- For each row, through all columns (j: 0→4)
Each LED stays on for 100ms before moving to the next.
File: examples/SfogliaPiani/SfogliaPiani.ino
Demonstrates layer control by cycling through all five layers of the cube, building each layer LED by LED.
- Layer filling using tensor and
stampaPiano() - Progressive layer building
- Layer-by-layer display
- Standard Cubong setup with 4 control pins
- For each layer (k: 0→4):
- Fill the layer LED by LED
- Display each progressive state
- 100ms delay per LED
- Clear and repeat
File: examples/SfogliaPiani_Vuoto/SfogliaPiani_Vuoto.ino
Similar to SfogliaPiani but starts with empty layers and cycles through them.
- Layer activation using
piano() - Simple layer cycling
- Minimal code example
- Standard Cubong setup
Cycles through layers 0-4 with a 500ms delay between each layer, keeping each layer fully lit when active.
File: examples/SfogliaPiani_input/SfogliaPiani_input.ino
Interactive layer cycling where the speed is controlled by an analog input (potentiometer).
- Analog input for interactive control
- Variable delay based on user input
- Layer cycling with
piano()
- Standard Cubong setup
- Potentiometer on analog pin A0
- Reads analog value from A0
- Maps value to delay (0-1000ms)
- Cycles through layers with calculated delay
Adjust the potentiometer to control the speed of layer cycling.
File: examples/StampaTensore/StampaTensore.ino
Demonstrates the tensor system by creating patterns and displaying them on the cube.
- Tensor manipulation
- The
stampaPiano()function - Pattern creation
- Standard Cubong setup with 4 control pins
Creates a specific pattern using the tensor system and displays it layer by layer.
File: examples/StampaTensore_Piani/StampaTensore_Piani.ino
Shows how to build complex patterns layer by layer using the tensor system.
- Layer-by-layer pattern construction
- Tensor
add()method - Progressive pattern building
- Tensor clearing with
azzeraTensore()
- Standard Cubong setup with 4 control pins
- For each layer (k: 0→4):
- For each position in the layer:
- Add LED to tensor:
add(i, j, k) - Display the layer:
stampaPiano(k) - 100ms delay
- Add LED to tensor:
- For each position in the layer:
- Clear tensor and repeat
This creates a visual effect of each layer being built up LED by LED.
File: examples/LampeggiaCubo_Input/LampeggiaCubo_Input.ino
Demonstrates the blinking/flashing functionality with variable delay controlled by analog input.
- The
lampeggiaCubo()function - Analog input for interactive control
- Blinking patterns
- Standard Cubong setup
- Potentiometer on analog pin A0
- Reads analog input
- Maps to delay value
- Blinks the cube with the specified delay
- Displays timing information on Serial monitor
Adjust the potentiometer to change the blinking speed.
- Open Arduino IDE
- Go to File → Examples → Cubong → [Example Name]
- Select your Arduino board: Tools → Board
- Select the correct port: Tools → Port
- Upload the sketch to your Arduino
- Observe the pattern on your LED cube!
No LEDs lighting up:
- Check your wiring connections
- Verify power supply is adequate
- Check that pin numbers match your hardware setup
Flickering or dim LEDs:
- May need to increase refresh rate
- Check power supply capacity
- Verify resistor values are appropriate
Only some layers working:
- Check layer control pins (l0-l4)
- Verify ULN2003 connections
- Test each layer pin individually
All examples can be modified to fit your specific hardware configuration. Key parameters to adjust:
- Pin numbers in the Cubong constructor
- Delay values for animation speed
- Pattern coordinates for custom designs
- Analog input pins for interactive examples
Use these examples as templates:
- Start with TestTensore for basic tensor usage
- Use StampaTensore_Piani to build layer-by-layer
- Check Miss for text patterns
- Study RiempiCubo for random animations
- SfogliaPiani_Vuoto - Simplest example, just layer cycling
- RiempiCubo - Simple random filling
- SfogliaLed - Triple nested loops
- StampaTensore_Piani - Tensor manipulation
- SfogliaPiani - Progressive building
- Miss - Text display and positioning
- LampeggiaCubo_Input - Complex timing and input
- TestTensore - Full tensor system demonstration
For more information:
- See the main README.md for API reference
- Check README_IT.md for Italian documentation
- Review the source code in
Cubong.cppfor implementation details
Happy coding! 🎨💡