Pages: [1]   Go Down
Author Topic: arduino, raspberry pi, tlc5940's  (Read 900 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I want to create a webpage on the raspberry pi so people can visually sequence LED's.

I have 32rgb led's and a color wheel of 96 posibilities (97 if you count off). I'm thinking I need to setup my arduino to listen for a long variable for each frame, decode it and send it to the tlc's. So we need a four digit number per led. two for position, and two for the position in the color wheel plus another 4 for the delay so it need to read 50 characters. something like 004501460223036704000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031560050

so the arduino will break it down per LED
channel 00 will load up the color wheel position 45, channel 01 will load color wheel position 46 etc... Delay of 50

I'm not quite sure if it can handle that large of a number being passed to it, maybe it needs to listen and concatenate the numbers or fill an array.

I plan on having 10 -32 frames of these 50 char variables, so would it be better to listen to it all then go with it, or process each frame at a time?

On the raspberry pi side I just need to write the webpage to 50 char variable to send on the serial line which should* be easy for me.

Any insight would be greatly appreciated.

here is what I have already with an arduino and tlc5940's with high powered leds
http://www.youtube.com/embed/kwIKgy6EBoQ



Logged

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

Adding start and end markers to the packet makes it a lot easier for the Arduino to read and comprehend. It also allows for adding something like <stringLen:string>, so you know how much data there is supposed to be, so you can ignore incomplete/corrupt packets.

What you are sending isn't a number its a string of characters that are all numeric.

Each packet will be sent one at a time, presumably, so that is the way that the Arduino should read them.
Logged

Denver, CO
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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;
   }
 
}
Logged

Denver, CO
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also note for site admins!! I started this thread "Krolo" but idk why it showed up as "sermat"
Logged

Denver, CO
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

for the pi i'm assuming all i have to do is create a simple script such as:

Code:
import time
import serial
 
#configure the serial connection
 
ser = serial.Serial("/dev/ttyACM0",9600)
 
ser.open()
 
# add some time delays to stop the Arduino resetting
 
time.sleep(1.5)
 
ser.isOpen()
 
time.sleetp(1.5)
 
ser.write("10,50,12,0,0,0,45,78,54,56,0,45,21,22,74,65,41,23,22,0,0,0,12,51,85,95,45,52,65,7,07,32,50+")
Logged

Pages: [1]   Go Up
Jump to: