Arduino Serial Communication

Hello!

I have a question. For example, i have 2 arduino, A and B. I able to send data from B to A using write() and read() function. But i can't send data from A to B using the same way. Hope there is someone help me with this question i had.

Thanks before!

Please tell what problems are you having. Are you having any coding problems, or the data is not being recieved? Please tell in detail.

..Arnav

mint123:
I have a question. For example, i have 2 arduino, A and B. I able to send data from B to A using write() and read() function. But i can't send data from A to B using the same way. Hope there is someone help me with this question i had.

That should be possible but you need to post your two programs and a diagram showing how things are connected.

What Arduino boards are you using?

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

You may also wish to consider whether it would be easier to communicate between two Arduinos (especially if you are using Unos or nanos) using I2C. See this Arduino to Arduino I2C Tutorial

...R