Robotic Avoidance Car
Dust Detector Car Action SKetch

Betty and I were casting about for things to keep our great grands busy when I ran across some info on Robots, specifically RobotCars.   I had just completed the Dust Sensor project for my large dust collection system which involved Raspberry pi and Arduino.   One car particularly caugh my interest, a robotic avoidance car, it was cheap and relatively simple, so I sprung for it.   Little did I know this would become a major project!      

This Robot Avoidance Car is operated by an Arduino Uno, and has an ultrasonic distance sensor.   The actuators are two TT DcMotors driving the wheels and an SG90 servo aiming the ultrasonic distance sensor.   I didn't know anything about servo sysems except the antenna servos in radar systems, and that had been a very long time ago.   These actuators were small and cheap looking compared to radar antenna servos.   After some research I discovered the two wheel drive actuators are DC Motors which had a driver board which with a dual H bridge to control direction, and an actual SG90 servo motor that directed the ultra sonic distance sensor.   The system also had a sensor shield (shield is the Arduino name for an extension board) which allowed everything to plug together.   The sensor shield (V5.0) was, in essence, a breakout board with plugs for most of the Arduino's digital and analog pins.   This turned out to be fortunate for me since the original avoidance software (sketch) didn't use a workable set of pins.   I had to shift some wiring around to get the drive motor speed control to work via PWM (Pulse Width Modulation).   Turns out the Arduino Uno only does PWM on a few of it's digital I/O pins and the frequency doubles on some, so I chose D3 and D11 as my speed control outputs.   I connected them to the L298 motor controller Ena 1 (Left) and Ena 2 (Right), respectively.   I had to move the motor crontroller's IN-1, IN-2, IN-3, and IN-4 to D0, D1, D2, and D4 respectively, documented in the Sketch.   I also had to move the servo control pin to D-12.   I slightly modified the wiring, I made the power switch kill battery power to the Uno as well as the motor drivers, originally the Uno was running anytime batteries were installed.   I also got some 1/4" X 1" sticky back weather strip foam and made foam tires for the wheels so they wouldn't slip on our laminate floors.

This thing is a hoot to watch, especially when it confronts an object, stops then appears to look left, then right before backing away and turning.   Betty suggested we put a distance sensor in the back, I'm thinking about it.   There is also code in the sketch for running the drive motors FAST or SLOW, I commented out the FAST option to prevent slipping on our floors.

Great grandson Ian was playing with it and said it should be named "Bat" because it uses ultrasonics to find it's way.   Well I thought that was a good idea!   He also suggested we add some bat wings since it would look cool.   As much as the car does side swipe things, I don't thing wings projecting out the sides would be a good idea, at this stage.   Maybe after I work on the code some more and keep it from sideswiping chairs etc.  
Ian got to looking at it and suggested I lower the angle of the ultrasonic distance sensor, and I thing that is also a good idea.

Car

The finished car from the top.  



Front view.   Note the distance sensor almost appears as if they were eyes.



The on-board Sensor Shield V5.0 which doesn't have any real drivers it is actually a breakout board.   You can see the wires connected to it.   From right to left, D-00 to D-13, D-00 - D02 (Grn,Blu,Purp) go the the L298, In-1, IN-2, IN-3.   D03 (Yel) goes to the L298 ENA-1 (left car motor), D-04 (Gry) goes to L298 IN-4 and D-11 goes to L298 ENA-2 (right car motor).   D-08 is the Sensor Trigger, and D-09 is the Echo, D-12 is the Sensor's direction Servo.



Ths L298's wiring: Yel=ENA1, Grn=IN1,Blu=IN2,Purp=IN3,Gr=IN4, Wt=ENA2.   Note the right motor lead wires connected to the two screw terminal block, Red (+) wire toward the heat sink on the L298.   The left motor leads connect to the other side two screw terminals, red lead nearest the heat sink.



Back side of the Sensor Shield.  



Note the foam rubber (weather strip) tires on the car.   The foam s 1" wide but I had split it for narrower pieces, you can see some of the split in other pics.



A little better look at the Arduion Uno under the sensor shield.   I modified the power plug, I removed a strain relief which made the lead wires want to drag on the tire.



Back of the distance sensor.   You can barely see the servo wires and the sensor wires.



Close up of Echo Ranging distance Sensor.   You can see the HS-405 and the SG90 servo (upside down) under it.  



One of the TT DcMotors that drive the wheels.   Right now I'm not using an optical sensor to detect the rotation of the wheels, but I think I will in the future.   You can see the rotation sensor "wheel" on the inboard end of the motor shaft.



The car wheels were still spinning (losing traction) even after I added the foam tires, so I added two 1/2 oz. weights just in front of the motors.   The car's original design has the battery pack at the rear above the caster wheel, it should be above the drive wheels.



Action

It has stopped at the door jam.  



You can see the distance sensor "looking" right and left to figure out which way to turn.  



It has moved around and "sees" the wall, now it's "looking" left.