I don't know how to write an application which can control the hardware.

  1. Google. Believe me, all these things have been done over and over and over and over again.
  2. Find out which examples are relevant to your specific hardware and your specific application.
  3. Read this.
  4. Feel free to post your questions!

And remember: the more specific the question, the more specific the answer (and the other way around as this reply shows you).