Refactor to handle old and new Arduino versions without code duplication as suggested by #14.