Need Help Making an LED Rubik's Cube

Hey Everyone, first time posting here!

So the title says it all. I'm in a introductory electronics course and desperately need some help with my final project. We are allowed to use any resources out there, so I'm coming to you all!

Our group is going to build a 3x3 LED cube equipped with 12 buttons to simulate the real deal. The rub is that besides from a two day Arudino workshop, I have no coding experience whatsoever. Here's where I am so far.

I know that we'll need individual control over 54 RGB LED's, which means 162 ports. In addition, we'll need 12 buttons for each possible rotation, so we're looking at ~174 ports in general. For the multiplexing, I will be using ~25 STP16C596 shift registers. I realize there are better ones out there, but this is what we're going with.

At this point, my biggest struggle is coding for this many shift registers. I have a good idea of what I need to do, but don't know how to accomplish it. To get started I've been studying the example code that came with my Arduino. It uses the shift register I am planning to use, which is basically why I chose it. I've put the code at the bottom without all of the comments.

I really like the shiftWrite function they defined, but don't know how to extend it to multiple shift registers. The function basically let's you control any port on one shift register using a function analogous to digitalWrite on the arduino.

Provided I CAN individually write to whatever port on whatever shift register I want, my plan was this:

  1. Create one variable for each port on each shift register, and one variable for the status of each port that will be equal to either one or zero, (on or off).

  2. Properly assign all of the variable so that the Cube will appear solved on start-up. This will require keeping track of which variables belong to which LED.

  3. Write out 12 functions to be executed with push buttons. Each function will effectively swap the variables associated certain ports in order to properly change the LED's (I have written exactly what needs to be swapped for each move).

Here is the example code, by the way.

nt datapin = 2;
int clockpin = 3;
int latchpin = 4;
byte data = 0;

void setup()
{

pinMode(datapin, OUTPUT);
pinMode(clockpin, OUTPUT);
pinMode(latchpin, OUTPUT);
}

void loop()
{
oneAfterAnother();
}

void shiftWrite(int desiredPin, boolean desiredState)
{
bitWrite(data,desiredPin,desiredState);
shiftOut(datapin, clockpin, MSBFIRST, data);
digitalWrite(latchpin, HIGH);
digitalWrite(latchpin, LOW);
}

void oneAfterAnother()
{
int index;
int delayTime = 100;

for(index = 0; index <= 7; index++)
{
shiftWrite(index, HIGH);
delay(delayTime);
}

for(index = 7; index >= 0; index–)
{
shiftWrite(index, LOW);
delay(delayTime);
}
}
void binaryCount()
{
int delayTime = 1000; // time (milliseconds) to pause between LEDs
// make this smaller for faster switching

// Send the data byte to the shift register:

shiftOut(datapin, clockpin, MSBFIRST, data);

// Toggle the latch pin to make the data appear at the outputs:

digitalWrite(latchpin, HIGH);
digitalWrite(latchpin, LOW);

// Add one to data, and repeat!
// (Because a byte type can only store numbers from 0 to 255,
// if we add more than that, it will “roll around” back to 0
// and start over).

data++;

// Delay so you can see what’s going on:

delay(delayTime);
}

go back and edit your post and put your code in code tags so it looks like this:

    code here

I'm sorry. I'm so new here I have no idea how to do that.

Then read the how to use this forum sticky post.