No serial data sent to pure data until "serial monitor" is opened at least once

Hi!

I just switched over from an Arduino Uno using to an adafruit feather. On the UNO, I had been using softserial to send very simple 1 digit codes to Pure Data (running on a rasberry pi). It was workign fine.

Now I am trying to do the same thing but using native USB and Serial rather than softserial.

However, it will not send any data to PureData until I have opened the serial monitor using the arduino IDE once. As soon as I've opened the serial monitor and then closed it again, I can go back to pure data, open the comport there and send whatever data I want and it works fine. However, until I've opened the serial monitor at least once, no data comes through AT ALL to pure data.

I can't figure why this would be.

Here's the relevant portions of the code (HUGELY simplified....)

#include "Arduino.h"
int incoming;
int button;

int RecPress = 0; // send 1 to pure data (pure data uses this to trigger "RECORD")

#define R_switch A1

void setup()
{

Serial.begin(9600);

}

void loop()
{
// INCOMING DATA PROCESSING
if (Serial.available() > 0)
{
incoming = int(Serial.read());
}

RecPress=digitalRead(R_switch);

if (RecPress==HIGH&&recflag==0){
button=1;
recflag=1;
}

if (button>0) {
byte data=byte(button);
Serial.write(data);
delay(350);
button=0;
}

}

I'm new to using serial rather than softserial so I'm sure I'm missing something basic...

Thank you

When using the 32U4 processor with native USB support as used in the Leonardo you normally need to wait until USB is available (it takes longer to connect) before proceeding but as your using the UART serial on pins 0/1 then its name is Serial1

Serial.begin(115200);
while(!Serial);   // Give USB time to connect if it's present
Serial1.begin(9600); // Start UART serial on pins 0/1

Solved!

I needed to send a signal to the Arduino that the com channel was open.

Once I sent a DTR on code (Data Terminal Ready=1) it worked.

(In pure data that's a message box with (DTR 1) sent to the open com port. )

I think that the serial monitor was automatically sending that or something similar to the arudino, which is why if I opened the serial monitor first, then closed it, pure data would then work

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.