CE351 Lab 2023 Spring
Lab 5 - Robot Car
Name: Simon Gorman
Email: sbgorman@fortlewis.edu

1. Elegoo Smart Car Kit 3.0 v

2. Introduction
Build an Elegoo Smart Car then test the ultrasonic sensor, servo motor, and the IR emitter-receiver pairs.

3. Materials and Methods

Materials Quantity
Arduino Uno R3
1
HC-SR04 sensor
1





Task 1: Assemble the car
Smart Car Fritzing Wiring Diagram
Figure 01: Smart Car Fritzing Wiring Diagram

Car was already assembled by a previous class so I didn't have to do task 1.

Assembled Robot Car
Figure 02: Assembled Robot Car

Task 2: Test the ultrasonic HC-SR04 sensor

Used the following wiring diagram to connect the Arduino Uno R3 board to the HC-SR04 sensor:
Wiring diagram of Arduino Uno to HC-SR04 sensor
Figure 03: Wiring diagram for the Arduino Uno R3 to the HC-SR04 sensor

After downloading the HC-SR04.zip file, I added the "HC-SR04.zip" to the Arduino Library:
  1. Downloaded the HC-SR04.zip file
  2. Opened the Arduino IDE, clicked "Sketch" > "Include Library" > "Add .zip library" , and added the HC-SR04.zip (see Fig. 00)
  3. Then I found the example code (see Fig. 00) from the HC-SR04 library (see Fig. 00):

Adding the .zip file to the Arduino Library
Figure 04: Adding the HC-SR04.zip file to the Arduino library

Opening the example code for the HC-SR04 library
Figure 05: Finding the SR04_Example code
#include "SR04.h"
#define TRIG_PIN 12
#define ECHO_PIN 11
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;

void setup() {
  Serial.begin(9600);
  delay(1000);
}

void loop() {
  a=sr04.Distance();
  Serial.print(a);
  Serial.println("cm");
  delay(1000);
}

Figure 06: SR04_Example code from the HC-SR04 library

HC-SR04 sensor Arduino code and Serial Monitor display
Figure 07: Arduino code with Serial monitor

I ran the code and recorded the following video:


Video 01: Testing the Ultrasonic HC-SR04 sensor

Task 3: Test the servo motor
Tested the Servo Motor's turning abilities by using the following code:

Arduino code - Servo turning
Figure 08: Arduino code for turning the Servo Motor from 0 to 180 degrees


Video 02: Servo motor turning 0 to 180 degrees

Task 4: Use the example code to turn on the motors of the car
Uploaded the following example code to the robot car's Arduino:

Arduino code for turning on all the motors
Figure 09: Arduino code to turn on all the motors


Video 03: Robot car running with all of the motors turned on

Task 5: Line-tracking -- Test all three IR emitter-receiver pairs
Uploaded the following arduino code to test the middle, right, and left IR emitter-receiver pairs of the Robot Car:

Arduino code to test the left IR sensor
Figure 10: Arduino code for testing the IR emitter-receiver pairs with Serial Monitor prints

I tested the sensors separately by commenting out the other sensors (see Fig.10) so that only one sensor was reading and writing to the Serial Monitor. I also used black electrical tape and a white paper to test if the sensor prints a "1" if it senses a reflection (i.e., white paper) or a "0" if it doesn't sense a reflection (i.e., black electrical tape) as displayed in the following video (see Video 04):


Video 04: Testing IR emitter-receiver of Left sensor

I repeated the testing displayed in Video 04 for the middle and right sensor and they all were recognizing the difference between the black tape vs the white paper background.

Task 6: Remote Control - Smart Car Tournament - Mode 1
[]

Task 7: Remote Control - Mode 2 - 'Go Places' and 'Line Tracker' Mode
[]

Task 8: Obstacle Avoider
[]

4. Results
[]
5. Discussion
[]