Part 8: Attach Distance Sensor
Attach Distance Sensor Bracket
- Insert the distance sensor into the bracket
- Add zip ties to the distance sensor as shown, do not tighen the zip tie too much
- Do not be afraid to ask for assistance, this part is a bit tricky
- Locate the bracket in your kit
- Attach the bracket as pictured to the front servo. Be cautious not to change the position of the servo.
Add Code to rotate sensor
- Create a method to Center the rotator called rotatorCenter
- Add a call to write to position 90 degrees
- Add a similar method for rotatorRight using position 180
- Add a similar method for rotatorLeft using position 0
Testing
- First update the loop method in mazerunner
- Call rotatorCenter
- wait 2 seconds
- Call rotatorRight
- wait 2 seconds
Compile and Deploy this code to the Arduino. Make sure that the distance sensor is alternating between facing forward and facing right.
- Second change the loop method in mazerunner to call rotatorLeft instead of rotatorRight
Compile and Deploy this code to the Arduino. Make sure that the distance sensor is alternating between facing forward and facing left.