Fixed bugs in Arduino code