New arduino code with acceleration and fixes