Can I send and recieve data from serial?

Hello all,

In my project, I'm making my arduino talk with processing via serial port.

But I need to both send and receive data in my arduino. They can be just 1 or 0s to just indicate on/off situation.

Is it possible to use serial port from arduino with .read and .write functions?

See "Communication" here.

Try some of the examples.

Thanks for quick response but I searched through the pages you suggested but I'm still not sure if sending and receiving data are separate or serial just has 1 value that can be changed by both ends.

In other words can I send and receive simultaneously or I have to send then clear and then receive?

Well, sending (from the Arduino) is blocking, so the function won't return until the last character has been sent. Receiving is buffered, so up to 128 characters will be received before characters are lost.

Try some of the examples.

If I open another serial port, (lets say 9601), and use it as receiving one, they won't block each other right?

9600 is the speed, not a port number

Yes you can send and receive at the same time. When you are sending the receiver still keeps gathering data and puts it in a buffer ready for when your program needs it.

serial just has 1 value that can be changed by both ends.

No serial uses a series of zeros and ones to transfer a byte from one unit to the other. There are two data paths, carried on two different wires, one sends and the other receives. See:-

Well I was manage to solve my problem as setting arduino. I set the code in a way that when it recieves a digit, gives a response according to it. Processing waits enough time to get the response.

I wasn't aware of two data lines, but thanks for your responses anyway.