General Description: This was a small-scale prototype that was constructed using Mindstorm-EV3 parts with an Ardunio brain and two third-party ultrasonic sensors.
End Goal: The purpose was a small-scale proof of concept in making an autonomous rover that can avoid obstacles using sensors. Additionally, it was an opportunity to become familiar with the type of programming and engineering that would go into the final project.
We started off by building the basic Mindstorms robot design and then added on our own battery pack so that we could interface with the Arduino and EV shield.
We then added the Arduino Uno and EV shield to the top of the base robot, and used double-sided tape to hold the battery pack down. We also added two ultrasonic proximity sensors to the front, attached with a custom-built 3D printed adapter that fits the third-party sensors and the Lego axle together.
Finally, we wired everything together, and connected the motors to the appropriate hubs on the EV shield. We had to use single-strand cables to connect the sensors and Arduino, and multi-strand cables to interface with the Mindstorms motors.
Video Documentation Of Final Obstacle-Avoidance Robot
The first ~20 lines of code were used to import the required libraries for interfacing with the Mindstorm parts. Objects to interface with the shield and shield-LEDs were also declared along with a few variables.
In the void setup (the part of the code that only runs once) the Serial monitor is started, the shield is initialised, the motors are reset, and the two ultrasonic sensors are initialised.
In the void loop, (or the part of the code that loops indefinitely) readings are taken from both ultrasonic sensors, printed to the serial monitor, and stored in variables. Then some if-statement logic-trains are used to determine when and how the motors should be turned on in order to most effectively avoid objects (this part is what could be fine-tuned the most).
In the final block of code, a few functions are defined to make moving the robot in certain ways more intuitive to code back in the loop function.