Serial communication in touchdesigner working with Uno but not with Mega

Hey I've been trying to send RGB values from touchdesigner to arduino to control 13 led strips.

It works on the Uno but it doesn't have enough memory to control 1800 leds. When I try to connect the Mega it doesn't recieve the RGB values. The RX light turns on when sending data though. I've tried varying baud rates and several arduino mega's and uno's. I'm sure I'm using the right COM ports.

I changed the code up for debugging purposes, it makes the leds white if the mega recieves any serial data at all. But nothing happens when I activatie serial com in touch designer. However, when I type something in the serial monitor it does react and turn the leds white. This leads me to believe the problem lies in touchdesigner. I don't know what the problem could be. Are there any differences between the Uno and Mega USB serial com I'm missing?

An alternative would be figuring out how to use less SRAM so I can use the Uno. I'm controlling 13 strips each with 100s of individually adressable leds. Using FastLED adding CRGB leds[1800]; uses 250% of the Unos memory. I only use 13 values though, sinc each strip has its own color. Maybe there's a way to reduce the memory usage?

Below is part of my code and my settings in touchdesigner.

char inputBuffer[numOfBytes];
int byteReturnLen = 0;
int byteReturnCounter = 0;
byte byteRead;

// ------------------- Setup -------------------- //
void setup() 
{
  
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, numLeds);
  
  FastLED.setBrightness(255);
  
  delay(500);
  Serial.begin(115200);
  Serial.setTimeout(500);
  FastLED.show();
}

// ------------------- Main Loop -------------------- //
void loop() 
{
  if(Serial.available() > 0) 
  {
     /* DEBUG TO TEST SERIAL read the most recent byte */
    byteRead = Serial.read();
    /*ECHO the value that was read, back to the serial port.*/
    Serial.write(byteRead);
    


    for (int i = 0; i < numLeds; i++) 
    {
      leds[i] = CRGB(255,255,255);
    
    }
    FastLED.show();
    byteReturnCounter = Serial.readBytes(inputBuffer, numOfBytes);
    byteReturnLen += byteReturnCounter;
  }
  
  if(byteReturnLen > 0)
  {
    /*for (int i = 0; i < NUM_STRIPS; i++) 
    {
      for(int j = 0; j < NUM_LEDS_PER_STRIP; j++)
      {
        leds[(i*NUM_LEDS_PER_STRIP)+j] = CRGB(inputBuffer[(i*3)+1],inputBuffer[(i*3)],inputBuffer[(i*3)+2]);
      }
      
    }*/
    
    FastLED.show();

    
    
    byteReturnLen = 0;
  }

  delay(10);
  
  
}

They are communicating when I disable DTR in touchdesigner. But then the values aren't being read properly so there's a lot of flickering.

That is not a complete program. The part where you #include the FastLED library and some of the data definitions are missing. The missing bit usually has the problem :slight_smile:

Are you saying that that exact program works on an Uno but not on a Mega? I find that hard to believe unless the FastLED library does not work with a Mega.

What is "touchdesigner"?

...R
Serial Input Basics

That is not my complete code no. It's the part that manages the serial communication. I don't think the problem is code related since it's running perfectly fine on a Uno. (at least not stuff like missing libraries and such). But I thought I might be overlooking a difference in serial communication between Uno and Mega.

Touch designer is the software I'm using to map animations for the leds on a 13x1 grid (13 strips each one color). It sends RGB values of 13 channels to arduino via serial. http://www.derivative.ca/

Jeffkeuh:
I don't think the problem is code related since it's running perfectly fine on a Uno

You have not specifically said if the exact same program won't work on the Mega. I am not clear whether you only tried the bigger code on the Mega.

Have you tried any other program on both Uno and Mega?

...R

The code also compiles and uploads fine on the mega. However, serial communication with Touch Designer specifically doesn't work. It does work when I try to communicate via the serial monitor.

The Uno recieves the bytes Touch Designer is sending, while the Mega (with the same sketch) doesn't.

My guess is that the FastLED stuff is not working properly on the Mega. However I have never used the FastLED library.

I presume the Mega can receive data from the Serial Monitor so that you know it is not broken.

Try taking all the FastLED stuff out of the program to see if the Mega can receive the data.

...R

Even the Uno is giving problems when using more leds, the more leds I use the more problems I get. They seem to appear random, like a part of the strip turning red when it shouldn't if I click a random button in the software that should have no effect on the serial communication. Testing with only 13 leds appears to work fine though.

Jeffkeuh:
Testing with only 13 leds appears to work fine though.

Do you mean on the Mega or on the Uno?

Have you tried my suggestion to disable the FastLED code?

It helps if you answer my questions so that I can follow my train of thought rather than jumping to some other ideas.

...R

On the Uno. And yes I have tried it without the fastled code. The Mega doesn't recieve serial communication from touchdesigner while it does recieve serial from Arduinos serial monitor.

That seems very strange. I have never had that sort of problem moving code from an Uno to a Mega. Are they both genuine Arduinos or is one or both a clone?

Have you the option, in touchdesigner, of enabling DTR (one of the serial control signals)?

Stick with the code that does nothing but receive serial data until you get this figured out.

...R