diff --git a/crawler_software/arduino/crawler_slave/crawler_slave.ino b/crawler_software/arduino/crawler_slave/crawler_slave.ino index 7ef159b..47abae0 100644 --- a/crawler_software/arduino/crawler_slave/crawler_slave.ino +++ b/crawler_software/arduino/crawler_slave/crawler_slave.ino @@ -15,15 +15,23 @@ int id; int val; void setup() { + // For debugging + //Serial.begin(115200); + // Attach the wiper servo to pin 9 windowWiperServo.attach(9); // This is the address the pi will speak to us at - Wire.begin(0x8); + Wire.begin(0x4); // Call receiveEvent when data received Wire.onReceive(receiveEvent); - + + // Setup LED + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + //Serial.println("Started"); } // Just loop to keep the running code alive, and wait for events to happen. @@ -33,9 +41,14 @@ void loop() { // This method runs when we receive a message void receiveEvent(int n) { - if (Wire.available() == 2) { // Dont do anything if this is not true + Wire.read(); + digitalWrite(LED_BUILTIN, HIGH); + if (true) { // Dont do anything if this is not true id = Wire.read(); // ID of the servo/device to access val = Wire.read(); // Value to assign + + //Serial.println(id); + //Serial.println(val); switch(id) { case 1: @@ -43,4 +56,5 @@ void receiveEvent(int n) { break; } } + digitalWrite(LED_BUILTIN, LOW); }