How does serial.available() work?

Hi, I've been playing with Arduino for a while, but now I'm working on other AVRs, I'm not allowed to use my Arduino for school projects.

I want to know how does serial.available() gets the bytes that are in the receiving buffer, what register or where does it reads that?

Thanks

As a byte comes in over the serial port it is put into a bit of memory, a buffer. It is counted, when you read a byte you get it from the buffer, it is un counted. serial.available simply returns the count of the number of bytes in the buffer.

Just have a look at the sources :)

If you do that and this is a school project, you should remember to list arduino in your list of sources :)

Good luck!