void loop() { delay(2000); // time to switch over to serial mode if (i < 1) { // do it only once for (b=0; b<64; b ++) { commandByte = b + B10000000; // add the latch command Serial.print("colorArray["); Serial.print(b, DEC); Serial.print("] = B"); Serial.print(commandByte, BIN); Serial.println(";"); } } i++; }
Just a heads up, this works because you add the 1 onto the left edge of the command byte by adding the actual value of the variable not by trying to tack it on with Serial.print before it. What I mean is that 63 prints out as 111111, 6 characters, but 23 is 10111, 5 characters. You can't just paste numbers to left edge with text and expect the value to be correct when you copy the printout. This writing your own program is way more time consuming for a non-numeric situation like writing out UP OFF DOWN and ON for the Synoptic Lab style code - In case you don't remember those lines look like: docolor(DOWN, DOWN, UP,128/(2*SPULSE),1); You'd start with something like the below, but I haven't tested it. void permutate(int n_options, int r_times) { int n; int r; for (r=0; r<r_times; r ++) { for (n=0; n><n_options; n ++) { Serial.print(r, DEC); Serial.print(" : "); Serial.print(n, DEC); Serial.print(" | "); } Serial.println(); } Serial.println(); }
I just borrowed Math is Fun >'s permutations and combinations calculator. They generate the list and then a bit of find and replace magic in BBEdit got me the code I needed. Oh, and for those of you who are curious and don't care about having a pre-written array the following function does work, and is what the attached video is of. void playAll() { int b; for (b=0; b<64; b ++) { nextColor = colorArray[b]; nextCommand = nextColor + B10000000; // latch it doColor2(nextCommand); } }
No comments:
Post a Comment