From 67daffd667dfb297d79434096296add1eb3e23d7 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Tue, 29 Jun 2021 22:57:51 -0400 Subject: [PATCH] Cleanup slave software again. --- .../arduino/crawler_slave/crawler_slave.ino | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/crawler_software/arduino/crawler_slave/crawler_slave.ino b/crawler_software/arduino/crawler_slave/crawler_slave.ino index 2388bec..447eef9 100644 --- a/crawler_software/arduino/crawler_slave/crawler_slave.ino +++ b/crawler_software/arduino/crawler_slave/crawler_slave.ino @@ -1,23 +1,20 @@ -/* Sweep - by BARRAGAN - This example code is in the public domain. - - modified 8 Nov 2013 - by Scott Fitzgerald - http://www.arduino.cc/en/Tutorial/Sweep -*/ +/* Crawler Slave + * + * This code runs on the crawler i2c network + * and provides a cleaner, less CPU intensive control over PWM devices. + */ #include #include -Servo myservo; // create servo object to control a servo -// twelve servo objects can be created on most boards - -int pos = 0; // variable to store the servo position +// This servo is used to wipe and clean the camera lens +Servo windowWiperServo; void setup() { - myservo.attach(9); // attaches the servo on pin 9 to the servo object + // Attach the wiper servo to pin 9 + windowWiperServo.attach(9); + // This is the address the pi will speak to us at Wire.begin(0x8); // Call receiveEvent when data received @@ -25,13 +22,15 @@ void setup() { } +// Just loop to keep the running code alive, and wait for events to happen. void loop() { - delay(10); + delay(50); } +// This method runs when we receive a message void receiveEvent(int howMany) { while (Wire.available()) { // loop through all but the last int pos = Wire.read(); // receive byte as a int - myservo.write(pos); + windowWiperServo.write(pos); } }