Hello,
I always look to see if there are examples that are already available that can help.
Look through the examples ( File > Examples…) that come with Processing:
And there are examples there for you that will help.
:)