Convert code into a proper Arduino library