Serial Monitor on new Leonardo does'nt show anything

Hello there,

I’ve problems with my new Arduino.
I had my code working on a 32u4 Pro Micro but ripped off the SMD USB Port, so I decided to go for something more robust and ordered a Leonard R3 replica. I’m wondering if the Serial Monitor isnt working anymore because of hardware differences? (New Chip is a 32u4-AU, old one was 32u4-MU)

I basicly put the Arduino between my Gamecube Controller and my Wii so I can visualize my Inputs for my stream. It also removes the deadzone of the controller. So the code is working just fine, means when I connect the Gamecube Controller to the Wii, the Controller works as expected. But when I open the Serial Monitor (or the 3rd Party program to visualize my inputs) nothing shows up. This worked on my 32u4 Pro Micro without any problems (after I changed the 3rd parties code and set DtrEnable, The Arduino IDE Serial Monitor sets DtrEnable too, so the problem has to be somewhere else). On the Pro Micro I didnt had to use

while (!serial)

and I want to avoid it because this would mean I cant use my Controller without the Serial Monitor open. One funny thing is when I use

while (!Serial)

My Controller will not do anything in my game, but as soon I open the Serial Monitor it works. This Means the Serial Communication is not broken but something inside Arduino IDE?

Maybe someone here has an Idea?

Thanks in regard,

Clyde

*Dont want to add 10 attachments (But I attached the Important stuff, I think), you can look up the full code here

ESS-Adapter.ino (2.65 KB)

input-display.cpp (579 Bytes)

*Dont want to add 10 attachments (But I attached the Important stuff, I think), you can look up the full code here
ESS-Adapter/ESS-Adapter at master · Skuzee/ESS-Adapter · GitHub

You can always attach a zipped version (give it the name of the sketch).

This worked on my 32u4 Pro Micro without any problems (after I changed the 3rd parties code and set DtrEnable, The Arduino IDE Serial Monitor sets DtrEnable too, so the problem has to be somewhere else). On the Pro Micro I didnt had to use

32U4 processors don't need DTR. Both the Leonardo and ProMicro are reset by opening and closing the serial port at 1200 baud.

and I want to avoid it because this would mean I cant use my Controller without the Serial Monitor open. One funny thing is when I use

while (!Serial)

My Controller will not do anything in my game, but as soon I open the Serial Monitor it works. This Means the Serial Communication is not broken but something inside Arduino IDE?

It's normal behaviour; you can work around it.

This is what I would use (demo code)

void setup()
{
  Serial.begin(57600);
}

void loop()
{
  // check if connection with PC is established
  if(Serial)
  {
    // some text to send
    char *msg = "Hello world";
    // only send over serial if there is enough space in the buffer; 2 added for CRLF
    if(Serial.availableForWrite() > sizeof(msg) + 2)
    {
      Serial.println(msg);
    }
  }
}

The availableForWrite() is needed in case you disconnect the USB and still have the board powered via external power. If you just send over Serial while the PC is no longer connected, you can bring your Arduino to a near-grinding halt. See Arduino Forum, analysis and solution from reply #6.

Note: if(Serial) and while(Serial) will only pick up if the PC gets connected, not if it gets disconnected.

Damn, thanks for you effort.
But it was just me being stupid... I just forgot to uncomment #define INPUT_DISPLAY

sterretje:
32U4 processors don't need DTR. Both the Leonardo and ProMicro are reset by opening and closing the serial port at 1200 baud.

I know reopening the serial monitor made my Input Display work but not the reason behind it,
but I saw several threads on here where they said it had to do with DtrEnable, so idk. But honestly adding the code
DtrEnable = true
to the Input Viewer Code was the easiest solution anyway.

But again, thanks for your help. I appreciate it alot!

Clyde