so I ran into a problem with string length because it would be longer the "long" can handle. I could split it up, but if I'm going to do that I might as well do it along the way with arrays and delimiters.
Will this work? My goal here is to populate the array, then execute it. The position of the array also corresponds to the position of the led. If this works I'll make it into a multidimensional array to accommodate sequences.
Code:
int color[32]; int delay = 0; int n = 0; int m = 0;
String txtMsg = ""; // a string for incoming text
void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
// send an intro: Serial.println("\n\nString length():"); Serial.println(); }
void loop() { // add any incoming characters to the String: while (Serial.available() > 0) { char inChar = Serial.read(); if(inChar==44){ // comma separated value for array ; color[n] = txtMsg; n++; txtMsg = 0; // i want to clear txtMsg but will this just append a zero at the front?; } else if (inChar==43){ // plus sign to signify last char which is the delay; delay = txtMsg;
** execute rest of code*** n = 0; m = 0; txtMsg = 0; } else { txtMsg += inChar; }
The TLC5940's and arduino are powered off a computer power supply. Whenever I introduce the usb just as a serial monitor everything shuts down, if I unplug it ever thing comes back on. I'm assuming it is because of introducing an additional ground to the circuit.
I want to have a raspberry pi run a webserver with php to and communicate to the arduino via usb. I have the arduino powering some tlc5940 driver chips and they are powered by an ATX power supply.
I am not able to use the usb serial monitor to my laptop when it is powered by the atx power supply (seperate grounds i'm assuming). Will I have any issues if the usb is plugged into the PI, like it does with my laptop?
Ah actually that should give me a nice spiral as well. I'm going to try this and I hope it gives me a spiral as well just a bit sharper: void fibi2(int endcount, int wait){
int sequence0[4]= {0, 9, 18, 27}; int sequence1[4]= {8, 17, 26, 4}; int sequence2[4]= {16, 25, 5, 12}; int sequence3[4]= {24, 6, 3, 20}; int sequence4[4]= {7, 14, 21, 28}; int sequence5[4]= {15, 22, 29, 3}; int sequence6[4]= {23, 30, 2, 11}; int sequence7[4]= {3, 1, 10, 19};
for (int howmanytimes = 0; howmanytimes < endcount; howmanytimes++){ Tlc.clear();
for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence0[k], bluepower[0]); Tlc.set(green + sequence0[k], greenpower[0]); Tlc.set(red + sequence0[k], redpower[0]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence1[k], bluepower[1]); Tlc.set(green + sequence1[k], greenpower[1]); Tlc.set(red + sequence1[k], redpower[1]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence2[k], bluepower[2]); Tlc.set(green + sequence2[k], greenpower[2]); Tlc.set(red + sequence2[k], redpower[2]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence3[k], bluepower[3]); Tlc.set(green + sequence3[k], greenpower[3]); Tlc.set(red + sequence3[k], redpower[3]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence4[k], bluepower[4]); Tlc.set(green + sequence4[k], greenpower[4]); Tlc.set(red + sequence4[k], redpower[4]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence5[k], bluepower[5]); Tlc.set(green + sequence5[k], greenpower[5]); Tlc.set(red + sequence5[k], redpower[5]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence6[k], bluepower[6]); Tlc.set(green + sequence6[k], greenpower[6]); Tlc.set(red + sequence6[k], redpower[6]); } for (int k = 0; k < 4; k++){ Tlc.set(blue + sequence7[k], bluepower[7]); Tlc.set(green + sequence7[k], greenpower[7]); Tlc.set(red + sequence7[k], redpower[7]); }
Tlc.update(); delay(wait); for ( int j = 0; j < 96; j++){ choice[j] = choice[j] + 3; if (choice[j] > 95 ){ choice[j] = 0; } } } }
I have attached the layout of the LED's. I am wanting to remap it so it will spiral into (or out of) itself. I rearranged it into a multidimensional array but the function does not do anything, maybe i'm missing something easy:
for (int howmanytimes = 0; howmanytimes < endcount; howmanytimes++){ Tlc.clear(); for (int k = 0; k < 4; k++){ for (int i = 0; i < 8; i++){
for ( int j = 0; j < 96; j++){ // this cycles the color wheel + 3 for each bluepower[?} etc.. choice[j] = choice[j] + 3; if (choice[j] > 95 ){ choice[j] = 0; } }
I want to make some LED lamps that are controlled by tlc5940 chips. The challenge is to synchronize them together from a master arduino located in a larger centerpiece and have 6 lamps surround it in a star topology anywhere from 8-20ft from the centerpiece.
1. Could I just run the tlc5940 signal lines to each lamp? or would the distance of >10ft degrade the signal too much? 2. put an arduino inside each lamp and connect all arduino's with the spi bus and have the master send out commands to six slaves.
I figured I would use cat5e for the spi lines or the tlc5940 signal lines but if there is a better alternative let me know.
I've got the tlc5940 code down pretty good but I have yet to network arduino's together or mess with any spi code.
Here is the final product built at Burning Man 2012 located at 4:45 and H
I took most of the video on the last day and by then it had some flickering issues that you may notice due to a signal wire connector but overall it turned out pretty good without any problems with electronics.