Testing code on device

I wanted to test my code on my iPhone/iPad like the instructor was doing on his iPad.

What steps are necessary to do this? Do I need a developer account with Apple? How do I set that up?