Refactor arduino functionality into a library.