Problem with serial comunication

Hello everybody :slight_smile:
I have a big problem with serial comunication. If I upload a sketch on Arduino Mega, serial comunication work correctly (With serial monitor I send a lot of information and the microcontroller responds correctly). But if I upload the same sketch on Arduino Uno, the microcontroller doesn’t respond correctly: I can only see the first response and after the serial tx crashes. Why?

Marlin.zip (65.4 KB)

Hi, What does your sketch do? What is the application?

Tom... :)

It is a firmware for 3D printer.

You using pins 0 and 1 for anything?

Also in configuration.h, there is this:

// The following define selects which electronics board you have.
// Please choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
    #define MOTHERBOARD BOARD_DUEMILANOVE_328P
#endif

Guess this should be set up for the uno?

Marlin is a very extensive and complex program.

Why not seek advice from its authors or perhaps on the RepRap forum ?

...R

tammytam: Guess this should be set up for the uno?

I forgot to delete these line of code. "MOTHERBOARD" isn't used anywhere. File "pins.h" contains the correct pin.

The Uno has a lot less memory than the Mega.

Also, you need to change the settings in the Arduino IDE and recompile the sketch. You can't just upload the same compiled file, it won't work.

michinyon: The Uno has a lot less memory than the Mega.

Also, you need to change the settings in the Arduino IDE and recompile the sketch. You can't just upload the same compiled file, it won't work.

I know that. I've already uploaded the sketch on Arduino Uno. So, it is not the problem.

Break down your sketch in functional components and try them one by one. It will give you better understanding of how the program works and where the problems arise. Harder work than posting on this forum, but extremely useful.

Merlin1960: Break down your sketch in functional components and try them one by one.

That is probably not practical with something as complex as Marlin - especially for an inexperienced programmer.

...R

You can try the below code to see if it works on the uno. If it works, then your issue is in your code and not the uno tx/rx.

//zoomkat 6-29-14 Simple serial echo test
//type or paste text in serial monitor and send

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("Simple serial echo test"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured String 
    readString="";
  } 
}