After many many hours of UI, code and coordinating with my cousin who is also a programmer we are ready to release the first version of a cube programmer. See the picture below. It can be downloaded via the links below, the first is the EXE file, the second is the source code in c# for the cube. Also the sketch is below that we used for the arduino.
Software Pic: http://www.twilightsavant.com/forumPics/cubeprogrammer1.jpg
http://www.twilightsavant.com/forumPics/cubeprogrammer1.zip
http://www.twilightsavant.com/forumPics/cubeprogrammersource1.zip
int latchPin = 2; //(Latch)
int clockPin = 3; //(Clock)
int dataPin = 4; //(Data)
long int shiftOutValues[5];
int currentRow = 0;
long int rcvdMessage[5];
int messageRow = 0;
unsigned long int readString;
void setup() {
Serial.begin(9600);
//set pins to output
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
//these are the actual numbers that get shifted out on each cycle (can't seem to store 32 digit binary in any type of var)
shiftOutValues[0] = 2231369727;
shiftOutValues[1] = 1107296255;
shiftOutValues[2] = 536870943;
shiftOutValues[3] = 268435487;
shiftOutValues[4] = 134217759;
}
void loop() {
for(int rowCount=0; rowCount<5; rowCount++) {
dataToRegisters(rowCount);
// delay(delayCount); //this is just here for debugging so we can see what is going on
}
int whileCounter=0;
while(Serial.available() > 0) {
//store what it gets
char incomingByte = Serial.read();
//this will get converted into a while depending on speed tests once we add the other rows to it
if(incomingByte == 'A') {
messageRow=0;
//reset the incoming buffer because we just started a new row
readString=NULL;
//Serial.println("Row A");
} else if(incomingByte == 'B') {
messageRow=1;
//reset the incoming buffer because we just started a new row
readString=NULL;
//Serial.println("Row B");
} else if(incomingByte == 'C') {
messageRow=2;
//reset the incoming buffer because we just started a new row
readString=NULL;
//Serial.println("Row C");
} else if(incomingByte == 'D') {
messageRow=3;
//reset the incoming buffer because we just started a new row
readString=NULL;
//Serial.println("Row D");
} else if(incomingByte == 'E') {
messageRow=4;
//reset the incoming buffer because we just started a new row
readString=NULL;
//Serial.println("Row E");
} else if(incomingByte == ',') { //look for the ending number sequence
rcvdMessage[messageRow] = readString; //save down the read string into the corresponding message row in our holding array
shiftOutValues[messageRow] = rcvdMessage[messageRow]; //for now kick this out, but we will be waiting for a full set of row instructions before this pushes in the final
//Serial.println("End of Sequence"); //debug msgs
//Serial.println(rcvdMessage[messageRow]); //debug msgs
} else {
readString *= 10;
readString += incomingByte - '0';
}
}
}
void dataToRegisters(int rowCount) {
unsigned long shiftdata = shiftOutValues[rowCount]; //grab the values for this row
unsigned long shiftmask = 1;
//set latchPin low to allow data flow
digitalWrite(latchPin, LOW);
//clear shift register ready for sending data (not sure why we have to do this but just do it! (maybe we can remove it later????)
digitalWrite(dataPin, LOW);
digitalWrite(clockPin, LOW);
for (byte i = 0; i < 32; i++) { //send all 32 bits out to the registers
digitalWrite(clockPin, LOW);
if (shiftdata & shiftmask) {
digitalWrite(dataPin, HIGH);
//Serial.print('1'); //send data to serial as well so we can see whats going on
}
else {
digitalWrite(dataPin, LOW);
//Serial.print('0'); //send data to serial as well so we can see whats going on
}
digitalWrite(clockPin, HIGH); //clock each bit into shift register
shiftmask = shiftmask * 2; //right shift bit mask one bit
}
digitalWrite(clockPin, LOW); //reset our clock pin just because
digitalWrite(latchPin, HIGH); //latch so the LEDs reflect the new patter
//Serial.println('B'); //ya just so we get a better debug
}