You are on page 1of 17

SHOW ME THE TRACK!

ARDUINO UNO MOTION TRACKER

Teras Quartet

Cabanlit, Jules

Hombed, Brian

Maloloy-on, Cris

Tiedra, Aprille Shane

College of Computing Education

University of Mindanao
SHOW ME THE TRACK! 2

PROJECT DESCRIPTION

Our project is an Arduino Uno Motion Tracker. With our project/device, we can track

the movement of an object and then applying the tracking data for further processing to rotate

the servo motor and match the movement of the object. In simple words, the device will face

the direction in which the object it tracked is located.

Our project will be based on the Arduino UNO with HC-SR04 ultrasonic sensor to

track the direction of an object. The Ultrasonic sensor will be used to determine the distance

and movement of an object like bats do. After determining the distance and direction of an

object it directly becomes an input that will be processed by the microcontroller and is sent to

the servo motor for it to rotate and track the direction of the object. This process is repeated

until the device is turned off.

The purpose of our Arduino Uno Motion Sensor is to simply know the behavior and

features of an object as tracking goes on. This is a basic project for the motion tracker and

can be applied to other projects that need a motion tracker or a sensor for any objects in the

vicinity like robots.


SHOW ME THE TRACK! 3

SKETCH

FIGURES 1,2,3: PSEUDOCODE OF THE TRACKER


SHOW ME THE TRACK! 4

The pseudocode above shows the trackers program design and how it should work. It

describes the algorithm behind the tracker. The sensor emits an ultrasound/sound waves

which travels through the air and if there is an object or obstacle on its path, it will bounce

back to the module. Considering the travel time and the speed of the sound you can calculate

the distance.

FIGURE 4: CIRCUIT DIAGRAM

This circuit diagram shows which wires to connect to the parts.


SHOW ME THE TRACK! 5

FIGURE 5: EXPECTED OUTPUT

This is the expected look of the assembled project. The ultrasonic sensor is attached to
the servo motor.

FIGURE 6: FINAL OUTPUT

This is the final output of our very own ARDUINO UNO MOTION TRACKER. It

comes with a lcd to display the distance, and it has two leds to indicate which side the tracker

is facing.
SHOW ME THE TRACK! 6

BLOCK DIAGRAM

Power Supply

9v
Battery

HC-SR04 Sensor SERVO MOTOR

Arduino Uno

R3

HC-SR04 Sensor SERVO MOTOR

9v
Battery
SHOW ME THE TRACK! 7

LOGIC FLOW CHART

START

Object SERVO MOTOR


in DIRECTS THE
OUT OF RANGE NO YES
range? SENSOR TO THE
OBJECT

SWITCH
END
NO ON YES
SHOW ME THE TRACK! 8

GENERALIZATION AND FINDINGS

The Motion Tracker was supposed to include not only the left and right direction, but
also the up and down directions. The proponents tried to achieve the desired output using four
of the HC-SR04 ultrasonic sensors along with two servos. Due to lacking resources and
limited amount of working time, the proponents were unable to accomplish the anticipated
final output. Thus, the group modified the proposed project and limited the directions into left
and right sides only. In order to fill the void and for innovation, the group added lcd, to
display the distance read by the sensors and leds, to indicate which side the tracker is facing.

Overall, it was found out physical properties of analog signals can be converted to
digital signals. A motion detector can be easily built using components that are readily
available. Working in groups helps because the members are able to share their ideas and
assist each other especially because everyone is talented differently. As for the project, there
is still room for improvement by tweaking some of the variables or even developing better
algorithms that improve upon this simple system. The supposed tracker that includes the up
and down directions can also be achieved if given enough amount of time and materials
necessary for successful operation. Potential applications for the motion tracker are obstacle
avoiding robots, motion following camera or turrets and other educational projects.
SHOW ME THE TRACK! 9

APPENDICES

APPENDIX A: MATERIALS AND FUNCTION

Arduino Uno - Arduino/Genuino Uno is a microcontroller

board based on the ATmega328P . It has 14 digital

input/output pins (of which 6 can be used as PWM outputs), 6

analog inputs, a 16 MHz quartz crystal, a USB connection, a

power jack, an ICSP header and a reset button. It contains

everything needed to support the microcontroller; simply

connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to

get started.

Ultrasonic Sensor (HC-SR04)- The HC-SR04 ultrasonic

sensor utilizes sonar to determine distance to an object like

bats do. It offers superb non-contact extend recognition with

high precision and stable readings in a simple to-utilize

bundle. From 2cm to 400 cm or 1" to 13 feet. Its operation is

not influenced by daylight or any dark material.

Servo- Servos are controlled by sending them a pulse of

variable width. The control wire is used to send this pulse. The

parameters for this pulse are that it has a minimum pulse, a

maximum pulse, and a repetition rate. Given the rotation

constraints of the servo, neutral is defined to be the position

where the servo has exactly the same amount of potential rotation in the clockwise direction
SHOW ME THE TRACK! 10

as it does in the counter clockwise direction. It is important to note that different servos will

have different constraints on their rotation but they all have a neutral position, and that

position is always around 1.5 milliseconds (ms).

Breadboard- A breadboard is a solderless device for

temporary prototype with electronics and test circuit designs.

Most electronic components in electronic circuits can be

interconnected by inserting their leads or terminals into the

holes and then making connections through wires where

appropriate. The breadboard has strips of metal underneath the board and connect the holes

on the top of the board. The metal strips are laid out as shown below. Note that the top and

bottom rows of holes are connected horizontally and split in the middle while the remaining

holes are connected vertically.

Battery (9V)- Batteries have three parts, an anode (-), a

cathode (+), and the electrolyte. The cathode and anode (the

positive and negative sides at either end of a traditional

battery) are hooked up to an electrical circuit. It serves as a

power source.

The chemical reactions in the battery causes a buildup of

electrons at the anode. This results in an electrical difference between the anode and the

cathode. You can think of this difference as an unstable build-up of the electrons. The

electrons wants to rearrange themselves to get rid of this difference. But they do this in a

certain way. Electrons repel each other and try to go to a place with fewer electrons. In a

battery, the only place to go is to the cathode. But, the electrolyte keeps the electrons from
SHOW ME THE TRACK! 11

going straight from the anode to the cathode within the battery. When the circuit is closed (a

wire connects the cathode and the anode) the electrons will be able to get to the cathode. In

the picture above, the electrons go through the wire, lighting the light bulb along the way.

This is one way of describing how electrical potential causes electrons to flow through the

circuit.

Jump Wires- A jumper wire is a conducting wire used to

transfer electrical signals between two points in a circuit. The

wires can either be used to modify circuits or to diagnose

problems within a circuit. Jumper wires typically vary in

color and size depending on what they are being used for. In

breadboards, jump wires are used to establish connections between the central micro

controller and other devices such as buttons and sensors.


SHOW ME THE TRACK! 12

APPENDIX B. DIAGRAMS

FIGURE S 1, 2,3: Pseudocode of the Tracker

FIGURE 4: Circuit Diagram

FIGURE 5: Expected Output

FIGURE 4: Final Output


SHOW ME THE TRACK! 13

APPENDIX C. CODES

/***********************************************************************************************
**Cabanlit,Hombed,Maloloy-on,Tiedra July 19, 107
************************************************************************************************
*/
#include <Servo.h>
Servo myservo;
const int Lin = 10, Rin = 12, Lout = 11, Rout = 13, serv = 9;
Rduration, Lduration, Rinches, Linches;//for duration&distance
int threshold = 10;
int angle = 80; //Initial angle
boolean debug = false;
void setup() {
if (debug) { Serial.begin(9600); } myservo.attach(9); }
void loop() {
pinMode(Rout, OUTPUT);
digitalWrite(Rout, LOW);
delayMicroseconds(2);
digitalWrite(Rout, HIGH);
delayMicroseconds(5);
digitalWrite(Rout, LOW);

Rduration = pulseIn(Rin, HIGH);


pinMode(Lout, OUTPUT);
digitalWrite(Lout, LOW);
delayMicroseconds(2);
digitalWrite(Lout, HIGH);
delayMicroseconds(5);
digitalWrite(Lout, LOW);
SHOW ME THE TRACK! 14

Lduration = pulseIn(Lin, HIGH);


Rinches=microsecondsToInches(Rduration);
Linches = microsecondsToInches(Lduration);
if (debug) { Serial.print("Left: ");
Serial.print(Linches);
Serial.println(" in");
Serial.print("Right: ");
Serial.print(Rinches);
Serial.println(" in"); }
follow(); }
long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
}
/***********************************************************************************************
**Cabanlit,Hombed,Maloloy-on,Tiedra July 21, 107
************************************************************************************************
*/
void follow() {
if (Linches <= threshold || Rinches <= threshold) {
if (Linches + 2 < Rinches) {
angle = angle - 2; }
if (Rinches + 2 < Linches) {
angle = angle + 2; }
} if (angle > 160) {
angle = 160;
}
if (angle < 0) {
angle = 0;
}
myservo.write(angle);
}
SHOW ME THE TRACK! 15

/***********************************************************************************************
**Cabanlit,Hombed,Maloloy-on,Tiedra August 3, 2017
************************************************************************************************
*/
#include Ultrasonic.h
#include Servo.h
int angle = 90;
Servo servoA;
Ultrasonic sensorB(7,6);
Ultrasonic sensorA(5,4);
void setup() {
servoA.attach(3);
}
void loop() {
int distanceA = sensorA.Ranging(CM);
int distanceB = sensorB.Ranging(CM);
if(distanceA < 51 && distanceB < 51){
if(distanceA < distanceB){
if(angle > 180){
angle++;
}
}
else{
if(angle > 0){
angle--;
}
}
servoA.write(angle);
}
}
SHOW ME THE TRACK! 16

REFERENCES

Nedelkovski, D. (2015, July 26). Ultrasonic Sensor HC-SR04 and Arduino Tutorial

Retrieved from http://www.howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-

sr04/

Calvin.(2015). Motion Following Robot

Retrieved from http://www.instructables.com/id/Motion-Following-Robot/


SHOW ME THE TRACK! 17

You might also like