Hi,
I’m trying to get the ‘SendTextToSerialDevice’ example to work with the Arduino using the Send Serial Data
node.
I have an Arduino sketch that reads serial data with a baud rate of 9600 but there doesn’t seem to be any data sent for some reason because Serial.available()
returns 0.
const unsigned int MAX_MESSAGE_LENGTH = 4;
void setup() {
Serial.begin(9600);
}
void loop() {
//Serial.println(Serial.available());
//Check to see if anything is available in the serial receive buffer
while (Serial.available() > 0)
{
//Create a place to hold the incoming message
static char message[MAX_MESSAGE_LENGTH];
static unsigned int message_pos = 0;
//Read the next available byte in the serial receive buffer
char inByte = Serial.read();
//Message coming in (check not terminating character) and guard for over message size
if ( inByte != '\n' && (message_pos < MAX_MESSAGE_LENGTH - 1) )
{
//Add the incoming byte to our message
message[message_pos] = inByte;
message_pos++;
}
//Full message received...
else
{
//Add null character to string
message[message_pos] = '\0';
//Print the message (or do other things)
//Serial.println(message);
//Or convert to integer and print
int number = atoi(message);
Serial.println(number);
//Reset for the next message
message_pos = 0;
}
//delay(100);
}
}
The Arduino sketch works fine since it receives data from the serial window. I have tried using the Configure Serial Device
node but I still have no data sent to the Arduino. I have also correctly selected the USB port on the Send Serial Data
node.
Has someone had success using the Send Serial Data
node?