Made changes to arduino code, moved calibrate funtions into their own function.