How does a spirometer work?

Can you answer this question?