diff --git a/crawler_software/arduino/crawler_slave/crawler_slave.ino b/crawler_software/arduino/crawler_slave/crawler_slave.ino index 8a1d2ee..7ef159b 100644 --- a/crawler_software/arduino/crawler_slave/crawler_slave.ino +++ b/crawler_software/arduino/crawler_slave/crawler_slave.ino @@ -33,12 +33,14 @@ void loop() { // This method runs when we receive a message void receiveEvent(int n) { - id = Wire.read(); // ID of the servo/device to access - val = Wire.read(); // Value to assign - - switch(id) { - case 1: - windowWiperServo.write(val); - break; + if (Wire.available() == 2) { // Dont do anything if this is not true + id = Wire.read(); // ID of the servo/device to access + val = Wire.read(); // Value to assign + + switch(id) { + case 1: + windowWiperServo.write(val); + break; + } } }