modified code to be used with arduino leonardo