Pages: 1 [2]   Go Down
Author Topic: 5x5x5 LED Cube w/ Animation Software Need Help  (Read 5204 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That makes sense. I just modified the GUI to send data out over the serial line, this is what it is sending, all on one line:

A2147749888,B1073741824,C537133056,D268435456,E134217728,

Hit me up with a personal message and your email and I can send you the source files and the executable if that would help. From looking at the serial port monitor I am running on the open port the comms look the same if you send them through the serial monitor in arduino IDE as when you send them through the GUI.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I sent you a PM. We can continue this off-line, tomorrow.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WOOT!!! I got it working this is what I had to do to be able to push a each byte (or number) onto the end of the unsigned long int:

Code:
readString *= 10;
      readString += incomingByte - '0';
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
readString *= 10;
This is an integer operation on a variable whose name implies that it is a string. You might want to give some thought to using names that don't cause incorrect assumptions to be made about their purpose.
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16506
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As in,  I_am_wealthy = house+wife+kids+bills;  ?

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you left a ! out there, somewhere. smiley-wink
Logged

Florida
Offline Offline
Sr. Member
****
Karma: 4
Posts: 431
hookedup!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think you left a ! out there, somewhere.

That was funny - a good laugh is a good way to start the day.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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
}
Logged

Pages: 1 [2]   Go Up
Jump to: