Arduino code to read and store switch and quadrature data