LED Cube

Hello Folks,
I am stuck to intilaize my cube..Here is the setup and loop functionality for your perusal..

Am I on the right path? I am confused with the shift register bits?

Please help!

include <SPI.h>

#define XAXIS 0
#define YAXIS 1
#define ZAXIS 2

#define POS_X 0
#define NEG_X 1
#define POS_Z 2
#define NEG_Z 3
#define POS_Y 4
#define NEG_Y 5

#define BUTTON_PIN 8
#define RED_LED 5
#define GREEN_LED 7

//changes made by me
#define SER_PIN 11
#define SRCLK_PIN 13
#define RCLK_PIN 10

#define TOTAL_EFFECTS 8
#define RAIN 0
#define PLANE_BOING 1
#define SEND_VOXELS 2
#define WOOP_WOOP 3
#define CUBE_JUMP 4
#define GLOW 5
#define TEXT 6
#define LIT 7

#define RAIN_TIME 260
#define PLANE_BOING_TIME 220
#define SEND_VOXELS_TIME 140
#define WOOP_WOOP_TIME 350
#define CUBE_JUMP_TIME 200
#define GLOW_TIME 8
#define TEXT_TIME 300
#define CLOCK_TIME 500

uint8_t characters[10][8] = {
{0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C}, //0
{0x10, 0x18, 0x14, 0x10, 0x10, 0x10, 0x10, 0x3C}, //1
{0x3C, 0x42, 0x40, 0x40, 0x3C, 0x02, 0x02, 0x7E}, //2
{0x3C, 0x40, 0x40, 0x3C, 0x40, 0x40, 0x42, 0x3C}, //3
{0x22, 0x22, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x20}, //4
{0x7E, 0x02, 0x02, 0x3E, 0x40, 0x40, 0x42, 0x3C}, //5
{0x3C, 0x02, 0x02, 0x3E, 0x42, 0x42, 0x42, 0x3C}, //6
{0x3C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, //7
{0x3C, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x42, 0x3C}, //8
{0x3C, 0x42, 0x42, 0x42, 0x3C, 0x40, 0x40, 0x3C}, //9
};

uint8_t cube[8][8];
uint8_t currentEffect;

uint16_t timer;

uint64_t randomTimer;

bool loading;

void setup() {

loading = true;
randomTimer = 0;
currentEffect = RAIN;

SPI.begin();
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);

//pins config
for(int i = 2;i<10;i++)
{
pinMode(i,OUTPUT);
}
pinMode(SER_PIN, OUTPUT);
pinMode(SRCLK_PIN,OUTPUT);
pinMode(RCLK_PIN,OUTPUT);

digitalWrite(SER_PIN,LOW);
digitalWrite(SRCLK_PIN,LOW);
digitalWrite(RCLK_PIN,LOW);

randomSeed(analogRead(0));
digitalWrite(GREEN_LED, HIGH);

}

void loop() {

randomTimer++;

if (digitalRead(BUTTON_PIN) == LOW) {
clearCube();
loading = true;
timer = 0;
currentEffect++;
if (currentEffect == TOTAL_EFFECTS) {
currentEffect = 0;
}
randomSeed(randomTimer);
randomTimer = 0;
digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED, LOW);
delay(500);
digitalWrite(RED_LED, LOW);
digitalWrite(GREEN_LED, HIGH);
}

switch (currentEffect) {
case RAIN: rain(); break;
case PLANE_BOING: planeBoing(); break;
case SEND_VOXELS: sendVoxels(); break;
case WOOP_WOOP: woopWoop(); break;
case CUBE_JUMP: cubeJump(); break;
case GLOW: glow(); break;
case TEXT: text("INSOFE", 10); break;
case LIT: lit(); break;
//case NORMDIST: normdist();break;

default: rain();
}

renderCube();

}

void renderCube() {
for (uint8_t i = 0; i < 8; i++) {
digitalWrite(SS, LOW);
SPI.transfer(0x01 << i);
for (uint8_t j = 0; j < 8; j++) {
SPI.transfer(cube*[j]);*

  • }*
  • digitalWrite(SS, HIGH);*
  • }*
    }

Go read the forum guidelines in the sticky post, then modify your post and correct it, including the things you forgot to include.

As above plus

Test your cube with a 5v supply to make you’ve put it together correctly.
things you missed : what doesn’t it do ?
What sized cube , circuit , which Arduino board, is that yr software or have you copied it ?
Have you tried shift register examples so you know how they work?

hammy:
As above plus

Test your cube with a 5v supply to make you’ve put it together correctly.
things you missed : what doesn’t it do ?
What sized cube , circuit , which Arduino board, is that yr software or have you copied it ?
Have you tried shift register examples so you know how they work?

Most of the effect code is copied except the comments given by me in the code..
I added the arduino pin connections in the code as they were not seen in the code..