Capstone Project Report 2016 final

90
Robotics Capstone 2016 Professor: Dr. Chen Students: Justin Estep Roberto Santos Benjamin Golson Johnathon Wheeler

Transcript of Capstone Project Report 2016 final

Page 1: Capstone Project Report 2016 final

Robotics Capstone 2016

Professor: Dr. Chen

Students:

Justin Estep

Roberto Santos

Benjamin Golson

Johnathon Wheeler

TABLE OF CONTENTS

Abstract...........................................................................................................................................1

Page 2: Capstone Project Report 2016 final

Proposed Timeline.........................................................................................................................3

Timeline Changes...........................................................................................................................5

Proposed Budget Table.................................................................................................................6

Updated Budget..............................................................................................................................7

Weekly Progress Report................................................................................................................9

Physical Assembly.........................................................................................................................17

Complications................................................................................................................................19

Resolutions.....................................................................................................................................21

Program Code..............................................................................................................................23

a) Arduino Mega with Ultrasonic Sensors. .....................................................................23

b) Left Arduino Uno with Speech Synthesizer................................................................31

c) Right Arduino Uno with RoboClaw............................................................................41

d) Transmitter Code.........................................................................................................51

Page 3: Capstone Project Report 2016 final

Abstract

This team set out to accomplish a culminating project required by the department to

demonstrate the versatile skills learned throughout the time spent at Austin Peay State

University. The team was composed of Benjamin Golson, Justin Estep, Johnathon Wheeler, and

Roberto Santos. The goal of our project is to create a Server Bot in order to attract future

students to the department. The use of Timbot 53 would cause students to be aware of the

program and allow an open line of communication to be created between the user and the

inquirer.

The concept of this project is to create a robot with the ability to halt when a person is

encountered. The robot will have ultrasonic sensors which will be activated when a distance is

reached between the sensor and the solid object. At this point the robot will communicate with

the individual based on predetermined dialogue. The robot will have the ability to introduce

itself, as well as give a brief description of its function.

The robot will have a wireless transmitter that can be used for multiple inputs; such as

teaching, stopping, or manual control of the robot. The interior of the robot will be composed

using an Arduino Uno microcontroller with several sensor for distance and wireless

transmission. The wireless transmitter will also consist of an Arduino Uno with wireless

transmission and LCD display for status checking of the Robot. The Arduino Uno has been

chosen as the microcontroller for these functions due to its versatility and the broad coding

availability in the Integrated Developer Environment. Arduino microcontrollers are an open

source programming language. The program may be written with the support of C and C++

language. We plan to code each sensor separately and compile the code at the end.

1

Page 4: Capstone Project Report 2016 final

The capstone project was accomplished through a span of sixteen weeks. This time gave

the group the ability to formulate ideas and experiment in the creation of a functioning robot. All

team members committed countless hours to ensure this project would be completed and meet

the desires set forth at the beginning of the semester. Prior to the commencement of our

education as a whole, the creation of this robot would have been extremely arduous. Using the

knowledge gained throughout the engineering technology program allowed us to create as well

as troubleshoot our desired project.

2

Page 5: Capstone Project Report 2016 final

Proposed Time Line

Objective Week

Project Overview

Timeline

Part List

1

Order Parts

Expand on project overview

Abstract

2

Sample Coding

Receiver Work

Design on Creo

3

Prototype Receiver Circuitry

Purchase Parts from Department Store 4

Assemble Body and Frame

Progress Report

5

Begin Coding for Rock Crawler

Inner Report

6

Rock Crawler Coding

Encoder Sensor Integration

Inner Report

7

Initial Debug

Project Overview Reevaluation

System Reevaluation

8

Human Sensor

Brake System

9

Voice Coding 10

3

Page 6: Capstone Project Report 2016 final

Brake System

Sensor Debug 11

Code Integration

Code Debug

12

Final Report

Debug System

13

Whole System Test

Report Continuation

Power Point

14

Debug System

Report Continuation

Power Point Continuation

15

Presentation

Demonstration

16

4

Page 7: Capstone Project Report 2016 final

Timeline Changes

Week 1: Week one remained as planned with the overview, timeline, and parts list being

created.

Week 2: Schedule was met as parts were ordered, project overview was expanded upon, and

abstract was created and presented.

Week 3: Schedule was exceeded as parts arrived early and contrition of the base was

initiated.

Week 4: Week four timeline was met as sample coding was created, wiring prototype was

accomplished and additional parts were purchased from department store.

Week 5: Week five schedule was met and exceeded as the combination of coding was created

in order to create the remote control available.

Week 6: Scheduled rock crawler coding was created but issues continued to arise with relay

used would be inadequate. Physical body of robot was discussed and agreed.

Week 7: Rock crawler coding was tested and robot purpose was reevaluated.

Week 8: Schedule was determined to be off course as assembly of body was not complete.

Fabrication of body initiated and additional materials were gathered at this time.

Week 9: Schedule was met as ultrasonic sensors were gathered and assembled. Early coding

for sensors was created.

Week 10: Schedule was determined to be behind as speech synthesizer was not coded and

ready for usage.

Week 11: Schedule was rectified as debugging of all coding commenced. 3D materials were

created and wiring was completed.

Week 12: Physical assembly was worked on while code debugging continued allowing the

projected timeline to be on met.

Week 13: System testing was met and code debugging continued.

Week 14: Body assembly was completed, whole system test and debugging continued.

Report and PowerPoint were initiated.

Week 15: System debugging continued and final report and PowerPoint was overviewed.

Debugging continued to be conducted on robot.

Week 16: Schedule was met as presentation was ready, final bug test was conducted, and

stationary mode was added to correct sentry mode.

5

Page 8: Capstone Project Report 2016 final

PROPOSED BUDGET TABLE

Tim Bot - 53 CapStone Project Parts Budget           

Web site Product Code Part NameQuantit

yPrice per

Unit total

    Eco Battery System 1 $199.00$199.0

0

robotshop.com RB-Sct-921 Mantis 4WD Off-Road Rover Kit 1 $329.99$329.9

9robotshop.com RB-Ard-35 Motor Driver Shield V3 1 $23.50 $23.50robotshop.com RB-Ada-18 Adafruit 6AA Battery Holder 1 $5.00 $5.00

robotshop.com RB-Dfr-552speech synthesis shield for Arduino 1 $43.68 $43.68

robotshop.com RB-Cyt-39 Cytron simple rotary encoder kit 2 $11.06 $22.12robotshop.com RB-Spa-1160 .25W thin Speaker 2 $0.95 $1.90sunfounder.co

m HC-SR04 ultrasonic distance sensor 4 $5.99 $23.96

sunfounder.com

joystick PS2 Module joystick ps2 Module 1 $9.99 $9.99

sparkfun.com WRL - 10532RF link Receiver - 4800bps (434MHz) 2 $4.95 $9.90

sparkfun.com WRL - 10534 RF Link Transmitter - 434MHz 2 $3.95 $7.90

adafruit.com 498RGB backlight negative LCD 20x4 1 $24.95 $24.95

On Hand   Aluminum Frame   $0.00 $0.00On Hand   Wheels 4 $0.00 $0.00On Hand   Bolts   $0.00 $0.00On Hand   Arduino Uno microcontroller 3 $0.00 $0.00On Hand   Push-Buttons 4 $0.00 $0.00On Hand   toggle switch 3 $0.00 $0.00On Hand   Wire   $0.00 $0.00Lowe's   paneling 4x8 (ft.) 1 $20.00 $20.00

        total cost$721.8

9

6

Page 9: Capstone Project Report 2016 final

Updated Budget

Tim Bot - 53 CapStone Project Parts Budget           

Web site Product Code Part Name Quantity

Price per Unit total

robotshop.com RB-Sct-921 Mantis 4WD Off-Road Rover Kit 1 $329.99 $329.99

Amazon RB0413 RoboClaw 2x30A Motor Controller 1 $124.95 $124.9

5

robotshop.com RB-Dfr-552 speech synthesis shield for Arduino 1 $43.68 $43.68

adafruit.com 498 RGB backlight negative LCD 20x4 1 $24.95 $24.95 sunfounder.co

m HC-SR04 ultrasonic distance sensor 8 $3.00 $23.96

On Hand   Arduino Mega 1 $13.00 $13.00 sunfounder.co

mjoystick PS2

Module joystick ps2 Module 1 $9.99 $9.99

sparkfun.com WRL - 10532 RF link Receiver - 4800bps (434MHz) 2 $4.95 $9.90

sparkfun.com WRL - 10534 RF Link Transmitter - 434MHz 2 $3.95 $7.90 robotshop.com RB-Ada-18 Adafruit 6AA Battery Holder 1 $5.00 $5.00

Local   Vinyl Graphics of Governor logo 3 $10.95 $32.85 Local   Vinyl Graphics of names 1 $10.95 $10.95

On Hand   Arduino Uno microcontroller 3 $0.00 $0.00 On Hand   Push-Buttons 4 $0.00 $0.00 On Hand   toggle switch 3 $0.00 $0.00 On Hand   wire   $0.00 $0.00 On Hand   Speaker w/ mount 1 $0.00 $0.00

On Hand   25" x 12" Expanded Metal (for base) 4 $0.00 $0.00

On Hand   24" x 1.5" Square rail (for base) 2 $0.00 $0.00 On Hand   27" x 1.5" Square rail (for base) 3 $0.00 $0.00 On Hand   "L" Brackets (for wheel mounts) 8 $0.00 $0.00

On Hand   2" Square Stock (for wheel mounts) 4 $0.00 $0.00

On Hand   End Caps 6 $0.00 $0.00 On Hand   1/4" Bolts 36 $0.00 $0.00 On Hand   1/4" Nuts 36 $0.00 $0.00 On Hand   Flat Washer 64 $0.00 $0.00

7

Page 10: Capstone Project Report 2016 final

On Hand   Lock Washers 34 $0.00 $0.00 On Hand   Breadboard 2 $0.00 $0.00 Donated   12V Disco Ball 1 $0.00 $0.00 On Hand   Battery Tray 1 $0.00 $0.00 On Hand   Heat Shrink 1 $0.00 $0.00 On Hand   1/2" EMT 40" stock 4 $0.00 $0.00 On Hand   1/2" EMT 1/2 circle hanger 32 $0.00 $0.00 On Hand   1/2" EMT Straights 1 $0.00 $0.00 On Hand   Sensor Metal Mount Plate 1 $0.00 $0.00 On Hand   1/2 Coupling EMT Mount 4 $0.00 $0.00 On Hand   Swivel Wheels 4 $0.00 $0.00 On Hand   6V, 7.5mh Batteries 2 $0.00 $0.00 On Hand   24"x .25"x 19.5" Plexiglas Panels 2 $0.00 $0.00 On Hand   23"x .25"x 19.5" Plexiglas Panels 2 $0.00 $0.00

        total cost $637.12

8

Page 11: Capstone Project Report 2016 final

Weekly Progress Report

Week 1: During week one the group discussed the minimum requirements for what would be

expected from the finished project. Ideally the expectation would be a robot that is roughly 3 feet

in height with a tray mounted to the top that would move around the room in a predetermined

path and stop when people approach a predetermined distance. The group then discussed the

parts that would be necessary to accomplish this task. After the discussion, a parts list was

gathered to include the website were the parts, unit price, the number of each part that would be

needed and the product code. Once the parts list was created and a clear understanding of what

task of the robot would be accomplishing a projected weekly timeline was establish to maintain a

clear focus on the final goal.

Week 2: Week two consisted of ordering parts required for the project as well as writing a

project proposal necessary for the initial presentation of the project. The proposal was written

and proposed in the first meeting. Soon after being presented and approved by Dr. Chin, the

professor, the parts were ordered. Several of the parts ordered were not available, causing

additional research to be done to find other websites that could offer the same product at a

comparable rate. The team members agreed on prices and began preparing a plan for week three

of the project.

Week 3: During week three many of the components arrived ahead of schedule. These include

the LCD Shield, Mantis rock crawler, encoder sensor, wireless transmitter/receiver unit, battery

pack, and Arduino Motor Shield. This encouraged the group to start construction of the Mantis

9

Page 12: Capstone Project Report 2016 final

rock crawler for testing. After construction, a short sample code was developed and tested on the

Motor Shield and Mantis. Once ensuring that the Mantis and Motor Shield were operational the

LCD Shield was assembled for testing. While testing the LCD Shield a controller layout was

designed on CREO, with plans to start construction and coding soon. Due to early part arrival,

the group would be able to start building and coding of most aspects of the project and setting the

project ahead of schedule going forward.

Week 4: Week four involved a discussion and adjustment of the initial frame. The construction

of a base frame for the Mantis with a 24”X24” IDEM was creating utilizing aluminum frame

square stock located in the lab. The wiring of Mantis was done for diagnostic purposes with the

independent motor control for the wheel assemblies being the primary concern. The sample code

created during the previous week was used to test the Arduino Uno board for functionality. All

though the Arduino Uno was programmed, it was unsuccessful and would be reassessed the

following week. The group began collaborating on ideas of material that could be used as

structural support for the serving tray apparatus.

Week 5: Week five numerous problems were encountered with the motor shield. The motor

shield that was originally ordered could not provide enough current to move the motors when a

load would be applied. Group members concluded that a relay would be a possible solution this

problem. As the code for the encoder was being developed, there was a realization that for the

encoder to provide an accurate count, it could not be connected to an independent motor. The

encoder’s count would be inaccurate due to the variety of intricate movement required per wheel

and would require an independent wheel that would move the wheel and spin the encoder. The

10

Page 13: Capstone Project Report 2016 final

code for the remote began to be created in stages, and the code for the LCD screen shield,

joystick, and transmitter were combined into a single working code. A list of commands would

be required to be transmitted between the remote and robot.

Week 6: In week six several issues were recognized after testing, it was acknowledged that the

relay was not the correct method. Upon further research, it was discovered that the 4wd Mantis

manufacturer recommended the use of a RoboClaw motor control. This motor control would be

able to provide the necessary maximum current necessary to move the motors even when there is

a weight barring load on the robot. Some concerns researched before ordering was the price, stall

current the RoboClaw would be able to handle, and finally the ability to connect with the

Arduino Uno microcontroller being used. The appropriate information was acquired, and the

RoboClaw was ordered via Amazon for rapid delivery. Due to the issue with the relay, there was

no way of completing a full test of the mantis. The upper frame material was discussed and

agreed upon by the group. The upper frame would consist of EMT being connected to each

corner and raised to reach a maximum height of 3 feet. A 40° bend would be given to the pipe to

provide a more aesthetically pleasing design to the overall robot. The frame would be built as

soon as the EMT could be acquired.

Week 7: During week seven the RoboClaw controller was received allowing the group to

commence sample coding with wiring was created providing the opportunity for testing. During

testing, it was discovered that the battery system originally ordered for use could not run the

Mantis rock crawler. The first mathematical current draw estimated for use by the Mantis and

sensors seemed accurate but unfortunately one crucial point was overseen when doing the initial

research for the battery. When researching the battery for purchase, the group failed to oversee

the safe functions provided by the battery, this proving to be a costly mistake as the battery

11

Page 14: Capstone Project Report 2016 final

originally purchased would no longer be used. To resolve the battery issue, serval other power

options were tested, and a solution was established that would function. With most issues

believed to be resolved the original idea and intent of the project be reexamined. As a group, it

was agreed upon that a genuine purpose of the project was to promote the department and not

necessarily for the robot to cater hors d'oeuvres. With this in mind, the group would push

forward to achieve this goal. The following week would be focused on coding and finishing the

mantis frame.

Week 8: During week eight the hardware for sentry mode and the motor shield, receiving and

transmitting code were all assembled. All stages of coding were initially created individually to

ensure that the sensors and systems worked properly. The fabrication of the EMT support frame

was set up with the intention of providing proper support and protection to the systems hardware

and internal frame. The height of 3 feet was ensured to work with the ultra-sonic sensors. As

these aspects of the project were assembled, there was a shift in focus as an interim presentation

was created to give the sensors and vision class an update on all accomplished tasks to that point.

Week 9: After returning from a week’s vacation as a group, all were ready to work full steam

ahead and achieve the task set out to be accomplished. The first step taken was the design and

print of a tray that would be used to hold the motor control (RoboClaw) and the two Arduino

Uno microcontroller’s that would be required to control the Timbot 53. The design was created

using Creo Parametric and the use of the 3D printing lab helped make the creation a reality. A

rapid tray prototype was created using a breadboard, and it was confirmed that the ultra-sonic

sensors need to be at least waist high to get an accurate reading on a person. Testing showed the

sensors being inaccurate when the signal bounced off of an individual’s legs. This denotes that

the sensors would be required to be at least 3ft. off the ground to be able to reliably detect a

12

Page 15: Capstone Project Report 2016 final

person, however, a child would be too small for the robot to see. A plate was proposed to hold

the ultrasonic sensors. The plate would be octagon shaped so that all eight sensors faced in a

different direction, this ensured that a person could be detected from any direction when

approaching the robot. It would also cover blind spots so that the robot would not run into

anyone. A few prototypes of the slots were the sensors would fit onto were printed. The intent

being for the sensor to slide into the slots which would be designed into the sensor tray. If

required, the design would be adjusted to ensure a secure fit. Two batteries were used to power

the mantis robot, and it was determined that the most efficient way to secure the batteries would

be to make a saddlebag type container that the batteries could be placed at. The container will be

centered on the mantis robot frame. The container was printed at the end of the week as it would

take 37 hours to 3D print the battery container.

Week 10: During week ten preliminary testing was conducted on the sensors, and it was

discovered that a basic Arduino Uno would not be able to handle all the sensor inputs and

outputs required by all eight ultrasonic sensors. The Arduino Uno initially was going to be

coded with the intent of having each sensor connected to the same trigger output pin to minimize

the required pins. Unfortunately, this design was not capable of providing all the trigger pins

with the necessary power and caused the sensors not to react appropriately. Further research

was conducted and proved that an Arduino Mega would be better suited for the pin input and

output as the Uno only has 14 pins while the Mega provides 54. The decision was made rapidly

to order a Mega so as to proceed with coding and wiring. At this point, it was determined that

the robot would break when the speed was lowered which could be controlled when programed.

Week 11: During week eleven many small tasks required finalization. These include leveling

mantis frame, ordering material for the 3d printer, simple wire fixes, controller housing design,

13

Page 16: Capstone Project Report 2016 final

mantis speed adjustment in code, controller housing test piece, controller functions and it was

discussed what the robot would say with the use of a speech shield. It was agreed upon that the

following week would launch the use of the 3d printer to print the sensor tray. Once this was

completed the initiation of multiple commands for the robot with a focus on the sensors and the

controller functions would be accomplished through the abilities of coding.

Week 12: During week twelve the focus was split between the physical assembly of the

Plexiglas as well as coding for the robot. In the physical aspect, the Plexiglas was cut to the

shape of trapezoid panels, and the usage of vinyl graphics would create a more aesthetically

pleasing view when combined with the sandblasted panels. As the Plexiglas was cut, two

Arduino Uno’s were mounted to the mantis as well as other hardware. The programming has

continued to be an issue as the combination of all the different sensors together would not go as

planned. The incorporation of various sensors and the lack of resources combining each

command gave the programmers a difficult time and numerous approaches were conducted to

find a suitable resolution to these issues. The use of “else/ if” statements in combination with

“while” statements would not blend properly and it was determined that it would be fixed as

debugging steps were taken.

Week 13: Sentry mode for the robot was a key and challenging coding aspect of the project.

Week thirteen was used to program the remote, but sentry mode was still essential to the robot's

motor control and the receiver. It was determined that the sonar required more work as they did

not work when trying to run them off of the spare pins on the two microcontrollers attached to

the robot. Preliminary coding done on the speech shield proved to be more difficult than

originally anticipated and the use of an outside source was required to help grasp a better

understanding of the code and its multifaceted functions. A meeting with an individual on the

14

Page 17: Capstone Project Report 2016 final

main campus was arranged to try and figure out how the code demands to be written to make the

speech shield work properly. The top portion of the remote control case was printed but the

overall case did not entirely suit the needs. This caused the group to redesign the casing but

ensuring the miscalculations and adjustments be incorporated to it.

Week 14: As the final weeks approached, week 14 was an important week as the robot’s frame

was assembled. The accomplishment of the frame gave all group members a visual reassurance

that the initial project that was set out to be accomplished could be met and even exceeded. This

served as a motivating aspect for the group and gave the members a sign of relief and a reminder

that the end is near. The panels were completed and attached to the frame as well as the

hardware being assembled, and the wires ran through the conduit allowing them not to be visible.

All code was initially tested and determined to work independently. Further debugging would be

required to ensure the programming and hardware would be able to work at a smoother flow.

Week 15: During week 15 the team committed to finishing several last minute touches on the

project. These include finalizing the display panels, printing and wiring the sensor tray, bug

testing sentry mode, and finishing the controller. Due to lack of print materials, we were forced

to use yellow as the tray color. To solve this, we just painted the tray to match the project's theme

color. As far as wiring we completed that and everything is functioning normally. Sentry Mode

still needs more bug testing which we plan on doing Monday. The controller also needs a top

printed with it as well as the top cover of the severing/ sensor tray. Looking forward, we have the

final presentation to do, and if Sentry Mode is not completed, we plan to chance it to stationary

mode.

15

Page 18: Capstone Project Report 2016 final

Week 16: The final week was the most time consuming. The finalization of the report and

PowerPoint was conducted. The presentation was reviewed and rehearsed to ensure the group

was ready for the presentation. The printing of the top cover for the sensors was finalized.

Group members made minor adjustments to the code in order to ensure there were no final issues

with it. After running numerous test it was determined that the 6V 7.5 mh. batteries would be

able to do the commands needed but the run time would not be sufficient for an extended period

of time. The suggestion for a bigger battery was determined and agreed upon by the group as

whole. It was understood that the batteries would have to be purchased and upgraded by further

groups if that group choose to expand upon the initial project.

16

Page 19: Capstone Project Report 2016 final

Physical Assembly

The physical assembly began with the use of four aluminum rails combined connected in a

square with the use of “L” brackets. Two of the aluminum rails measuring 24” x 1.5” while the

other two sides measure 27” x 1.5”. These rails were mounted to the mantis rover to give the

robot a base to move on the path determined by the user. Swivel wheels were added to all four

corners of the rails to distribute the weight evenly. Through the center of the railing square, an

additional 27” x 1.5” rail was attached to have the mantis rover rest over it. A speaker was

mounted to the front of the mantis which would be wired to the speech synthesizer. The mantis’

empty center cavity was used to house wires from the speaker as well as wires used to connect to

each DC motors. A Fortus 250 was utilized to 3D print a saddlebag housing carrying two 6V

batteries, one on each side. A breadboard was attached to the top end of the Mantis to house the

receiver and provide a 12V and 5V railing to each side. An additional tray was printed to

accommodate two Arduino Uno’s and a RoboClaw.

Each corner used the assembly of ½” EMT stock to give the paneling and expanded metal a

brace as well as creating housing for all components within the robot. The EMT stock was

connected to the frame with the use of four ½” coupling mounts. The EMT stock was bent at a

40° angle inverted to a center point at the top of the robot. All four bars were connected to a five

½” coupling mounts, which were welded together. A hole was drilled into two of the base

corners to distribute the wires needed to power the Arduino Mega. Each side required eight ½”

EMT ½ circle hangers. Four hooks were used to secure the 25” x 12” expanded metal which

primary focus was to protect the components used to control the robot. Above the expanded

metal a trapezoid Plexiglas panel was added serving more of a visual advertisement for the

department. All four of the panels were covered with a vinyl graphic then sandblasted over to

17

Page 20: Capstone Project Report 2016 final

give them a frost-like effect. After being sandblasted, the vinyl was removed leaving the

protected area clear of debris, making the sheltered area protrude. The Austin Peay logo was

used for three panels while the fourth panel had the capstone and students on it. The back side of

the panels was protected as well leaving the area clear and transparent. Once all aspects of the

body were complete, the top tray was assembled.

The top area of the robot was constructed with the use of a metal mount plate as the base and a

3D printed tray carrying eight ultrasonic sensors. The tray and mount were designed in the shape

of an octagon to decrease the chance of a blind spot. A blind spot could have increased the

likelihood of an accident making this robot a hazard. The 3d tray was secured to the metal with

bolts and wire was ran through the center of the coupling. The Arduino Mega was placed in the

center of the tray to communicate with the sensors.

18

Page 21: Capstone Project Report 2016 final

Complications

(Week 5) Throughout this project, numerous issues arose. The first incident occurred in

the fifth week as it was recognized that the motor shield would not be able to function with the

use of an Arduino Motor Shield. This device would be able to handle a maximum operating

voltage of 12V and a max current of 4A. The Mantis rover would require a stall current greater

than 4A just to operate. The encoder also became an issue as it was realized that the encoder

demanded an independent wheel to ensure an accurate count would be achieved.

(Week 6) During week six the introduction of a relay was realized to be ineffective. The

relay was incapable of interrupting or distributing the power each motor required. The relay

being used was far inferior to the power produced by the batteries and required by the mantis

rover.

(Week 7)Week seven carried the most crucial error caused by the group as a whole. The

Fenix Ready Start battery originally planned to be used was fully capable of providing the

required voltage and amps needed to power the robot. The problem with the utilization of this

battery was the manufacturers' safety precautions built into the battery. The battery would only

be capable of producing 2amps before triggering the safety causing it to shut off.

(Week 10) When programming the sensors, the use of trigger and echo pins played a key

element with the microcontroller. The initial intent was to have one trigger pin activate all eight

sensors. This would alleviate the use of 18 pins and only requiring eight pins in total. The pins

would be connected to a single Arduino Uno, which would communicate with the lower

Arduino’s. While programming, it was discovered that this concept could not be achievable.

19

Page 22: Capstone Project Report 2016 final

(Week 12) The speech shield was a time-consuming issue which the group was able to find no

resolution for. The speech shield required commands that none of the students were able to

create due to the complex demands requested by the group. The intent was for the speech

synthesizer to active when triggered by the ultrasonic sensor. A second problem was encountered

when drilling holes into the Plexiglas. The Plexiglas was cracked as when pressure was applied

to the panel causing the panel to be shattered.

(Week 13) Week thirteen brought forth three issues. The ultrasonic sensors were not able to

communicate with each other. When the trigger point was activated, the next sensor would not

activate. The second issue was the design of the remote control and the way the microcontroller

would fit inside of the casing which would be 3D printed. The final problem was the lack of

material color required to print the housing in the desired color.

20

Page 23: Capstone Project Report 2016 final

Resolutions

(Week 5) The initial resolution to the voltage requirements was to add a DC power relay

to provide the required power to each independent motor. If excessive power were produced

from the battery, the relay would help regulate it. When examining the encoder, it was

determined that if connected to an individual wheel from the mantis, the encoder counter would

not be accurate. It was determined that an extra wheel would be a better solution for the encoder,

but due to the lack of additional wheels available, it was determined that the encoder would not

be used.

(Week 6) Research conducted on the Mantis revealed that a RoboClaw controller was

recommended for usage. The RoboClaw controller would provide the amperage requested by

the mantis motors. The RoboClaw would replace the DC power relay originally suggested by

group members as a solution. The RoboClaw was research and purchased through Amazon.com

to provide rapid delivery.

(Week 7) After realizing that the Fenix battery had a built-in safety, the first idea was to open

the batteries and bypass the built-in safety feature. This idea was later rejected as it would

become a safety issue for future users. The second solution and safer of the two was to replace

the batteries for some that would be more feasible to the current and amp draw required for the

robot. The Fenix battery was replaced for two PS-670 6V 7.0 amp.hr. batteries. The two

batteries were connected in series to provide 12V which would power not only the mantis but all

other components as well.

(Week 10) While attempting to connect all ultrasonic sensors (18 pins) to the Arduino Uno so

pin usage could be minimal, it was detected that it was not going to fit the requirements sought

21

Page 24: Capstone Project Report 2016 final

after. Research conducted on this issue recommended the use of an Arduino Mega as the best

approach due to its maximum input of 54 pins and helping solve the obstacle.

(Week 12) Coding on the speech shield was tough to understand due to the inexperience of

coding by group members. After attempting to resolve the issue as a group, it was determined

that further help would be required. Help was obtained from a code developer known through a

third party. The individual proved to be very knowledgeable and helped solve issues attained.

(Week 13) An ongoing problem was the coding, the only way to fix the speech shield and

sonar sensors were to conduct debugging on the code. Debugging helped resolve the issue as

many were minor. The lack of material was an issue as it was available promptly. A different

colored material was used and painted to match the desired color scheme.

22

Page 25: Capstone Project Report 2016 final

Program Code

Arduino Mega with Ultrasonic Sensor

#define trigPin1 12//Trigger 1 FrontSensor

#define echoPin1 11//Echo 1 FrontSensor

#define trigPin2 10//Trigger 2 FrontRightSensor

#define echoPin2 9//Echo 2 FrontRightSensor

#define trigPin3 8//Trigger 3 RightSensor

#define echoPin3 7//Echo 3 RightSensor

#define trigPin4 6//Trigger 4 BackRightSensor

#define echoPin4 5// Echo 4 BackRightSensor

#define trigPin5 52// Trigger 5 BackSensor

#define echoPin5 51// Echo 5 BackSensor

#define trigPin6 50// Trigger 6 BackLeftSensor

#define echoPin6 49// Echo 6 BackLeftSensor

#define trigPin7 48// Trigger 7 LeftSensor

#define echoPin7 47// Echo 7 LeftSensor

#define trigPin8 46// Trigger 8 LeftFrontSensor

#define echoPin8 45// Echo 8 LeftFrontSensor

int Signal = 53;// Signal Out To Other Arduino

long duration, distance, FrontSensor, FrontRightSensor, RightSensor, BackRightSensor, BackSensor, BackLeftSensor, LeftSensor, LeftFrontSensor;// Sensor Array Setup

void setup()

{

Serial.begin (9600);// Serial Read OUT

pinMode(trigPin1, OUTPUT);// Trigger 1 setup

pinMode(echoPin1, INPUT);// Echo 1 setup

pinMode(trigPin2, OUTPUT);// Trigger 2 setup

pinMode(echoPin2, INPUT);// Echo 2 setup

23

Page 26: Capstone Project Report 2016 final

pinMode(trigPin3, OUTPUT);// Trigger 3 setup

pinMode(echoPin3, INPUT);// Echo 3 setup

pinMode(trigPin4, OUTPUT);// Trigger 4 setup

pinMode(echoPin4, INPUT);// Echo 4 setup

pinMode(trigPin5, OUTPUT);// Tigger 5 setup

pinMode(echoPin5, INPUT);// Echo 5 setup

pinMode(trigPin6, OUTPUT);// Tigger 6 setup

pinMode(echoPin6, INPUT);// Echo 6 setup

pinMode(trigPin7, OUTPUT);// Tigger 7 setup

pinMode(echoPin7, INPUT);// Echo 7 setup

pinMode(trigPin8, OUTPUT);// Tigger 8 setup

pinMode(echoPin8, INPUT);// Echo 8 setup

pinMode(Signal, OUTPUT);// Signal pin setup

}

void loop(){

//ReadSetUp

SonarSensor(trigPin1, echoPin1);

FrontSensor = distance;//

SonarSensor(trigPin2, echoPin2);

FrontRightSensor = distance;//

SonarSensor(trigPin3, echoPin3);

RightSensor = distance;//

SonarSensor(trigPin4, echoPin4);

BackRightSensor = distance;//

SonarSensor(trigPin5, echoPin5);

BackSensor = distance;//

SonarSensor(trigPin6, echoPin6);

BackLeftSensor = distance;//

24

Page 27: Capstone Project Report 2016 final

SonarSensor(trigPin7, echoPin7);

LeftSensor = distance;//

SonarSensor(trigPin8, echoPin8);

LeftFrontSensor = distance;//

//ReadSetUp

//Error Correction Section

if(FrontSensor == 5){

FrontSensor = 51;

}//

if(FrontSensor == 6){

FrontSensor =51;

}//

if(FrontRightSensor == 5){

FrontRightSensor = 51;

}//

if(FrontRightSensor == 6){

FrontRightSensor = 51;

}//

if(RightSensor == 5){

RightSensor = 51;

}//

if(RightSensor == 6){

RightSensor = 51;

}//

if(BackRightSensor == 5){

BackRightSensor = 51;

}//

if(BackRightSensor == 6){

25

Page 28: Capstone Project Report 2016 final

BackRightSensor = 51;

}//

if(BackSensor == 5){

BackSensor = 51;

}//

if(BackSensor == 6){

BackSensor = 51;

}//

if(BackLeftSensor == 5){

BackLeftSensor = 51;

}//

if(BackLeftSensor == 6){

BackLeftSensor = 51;

}//

if(LeftSensor == 5){

LeftSensor = 51;

}//

if(LeftSensor == 6){

LeftSensor = 51;

}//

if(LeftFrontSensor == 5){

LeftFrontSensor = 51;

}//

if(LeftFrontSensor == 6){

LeftFrontSensor = 51;

}//

//Error Correction Section

// Run Condition

26

Page 29: Capstone Project Report 2016 final

if(FrontSensor || FrontRightSensor || RightSensor || BackRightSensor || BackSensor || BackLeftSensor || LeftSensor || LeftFrontSensor >= 50) {

digitalWrite(Signal, HIGH);

}// Run Condition

// Stop Conditions

if(FrontSensor <= 49){

digitalWrite(Signal, LOW);

FrontRightSensor = FrontSensor;

RightSensor = FrontSensor;

BackRightSensor = FrontSensor;

BackSensor = FrontSensor;

BackLeftSensor = FrontSensor;

LeftSensor = FrontSensor;

LeftFrontSensor = FrontSensor;

delay(1000);

}//

if(FrontRightSensor <= 49){

digitalWrite(Signal, LOW);

FrontSensor = FrontRightSensor;

RightSensor = FrontRightSensor;

BackRightSensor = FrontRightSensor;

BackSensor = FrontRightSensor;

BackLeftSensor = FrontRightSensor;

LeftSensor = FrontRightSensor;

LeftFrontSensor = FrontRightSensor;

delay(1000);

}//

if(RightSensor <= 49){

27

Page 30: Capstone Project Report 2016 final

digitalWrite(Signal, LOW);

FrontSensor = RightSensor;

FrontRightSensor = RightSensor;

BackRightSensor = RightSensor;

BackSensor = RightSensor;

BackLeftSensor = RightSensor;

LeftSensor = RightSensor;

LeftFrontSensor = RightSensor;

delay(1000);

}//

if(BackRightSensor <= 49){

digitalWrite(Signal, LOW);

FrontSensor = BackRightSensor;

FrontRightSensor = BackRightSensor;

RightSensor = BackRightSensor;

BackSensor = BackRightSensor;

BackLeftSensor = BackRightSensor;

LeftSensor = BackRightSensor;

LeftFrontSensor = BackRightSensor;

delay(1000);

}//

if(BackSensor <= 49){

digitalWrite(Signal, LOW);

FrontSensor = BackSensor;

FrontRightSensor = BackSensor;

RightSensor = BackSensor;

BackRightSensor = BackSensor;

BackLeftSensor = BackSensor;

28

Page 31: Capstone Project Report 2016 final

LeftSensor = BackSensor;

LeftFrontSensor = BackSensor;

delay(1000);

}//

if(BackLeftSensor <= 49){

digitalWrite(Signal, LOW);

FrontSensor = BackLeftSensor;

FrontRightSensor = BackLeftSensor;

RightSensor = BackLeftSensor;

BackRightSensor = BackLeftSensor;

BackSensor = BackLeftSensor;

LeftSensor = BackLeftSensor;

LeftFrontSensor = BackLeftSensor;

delay(1000);

}//

if(LeftSensor <= 49){

digitalWrite(Signal, LOW);

FrontSensor = LeftSensor;

FrontRightSensor = LeftSensor;

RightSensor = LeftSensor;

BackRightSensor = LeftSensor;

BackSensor = LeftSensor;

BackLeftSensor = LeftSensor;

LeftFrontSensor = LeftSensor;

delay(1000);

}//

if(LeftFrontSensor <= 49){

digitalWrite(Signal, LOW);

29

Page 32: Capstone Project Report 2016 final

FrontSensor = LeftFrontSensor;

FrontRightSensor = LeftFrontSensor;

RightSensor = LeftFrontSensor;

BackRightSensor = LeftFrontSensor;

BackSensor = LeftFrontSensor;

BackLeftSensor = LeftFrontSensor;

LeftSensor = LeftFrontSensor;

delay(1000);

}//

// Stop Conditions Section

Serial.print(LeftSensor);

Serial.print("-");

Serial.print(FrontSensor);

Serial.print("-");

Serial.print(RightSensor);

Serial.print("-");

Serial.println(BackSensor);

}

void SonarSensor(int trigPin,int echoPin)

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

}

30

Page 33: Capstone Project Report 2016 final

Left Arduino Uno with Speech Synthesizer

/*the words created by the speech shield can't always be pronounced clearly.

to compinsate for this we are breaking difficult words into smaller words or syllables

and spelling them Phoneticly.

each letter is only able to create two sounds, the lowercase and the uppercase.

this means that sometimes it may be required to play with the spelling to find the correct sound.

*/

#include <SpeechSynthesis.h> // library required to opperate the speech shield

#include <VirtualWire.h> // library required to opperate the RF receiver

int x = 0; // x is the byte size of data receive by the receiver

int Start = 13; // the start command is used to activate autonomus mode

int Stop = 12; // tells the robot to stop autonomus mode

const int receive_pin = 11; // the receiver uses pin 11

int forward = 10; // forward is going to be the name of pin 10

int backward = 9; // backward is the name of pin 9

int right = 8; // right is the name of pin 8

int left = 7; // left is the name of pin 7

int Estop = 6; // tells the motors to stop if the emergency stop is pushed

int Mode2 = 5; // Mode2 is to tell the robot to enter senry mode

int Mode1 = 4; // mode1 is to tell the robot to enter manual mode

int Sensor = 3; // the sensor pin will recieve data from the ultra sonic sensors on the MEGA

int Save = 2; // this will tell the robot to save distance

int Mspeech1 = 0; // manual mode speech 1

int Mspeech2 = 0; // Manual mode speech 2

31

Page 34: Capstone Project Report 2016 final

int Mspeech3 = 0; // manual mode speech 3

int Wspeech = 0; //Wait mode speech

void setup()

{

//set these pins as output pins

pinMode(forward, OUTPUT);

pinMode(backward, OUTPUT);

pinMode(right, OUTPUT);

pinMode(left, OUTPUT);

pinMode(Mode1, OUTPUT);

pinMode(Mode2, OUTPUT);

pinMode(Save, OUTPUT);

pinMode(Start, OUTPUT);

pinMode(Stop, OUTPUT);

pinMode(Estop, OUTPUT);

// set this as an input pin

pinMode(Sensor, INPUT);

// Initialise the IO and ISR

vw_set_rx_pin(receive_pin);

vw_set_ptt_inverted(true); // Required for DR3100

vw_setup(2000); // Bits per sec

vw_rx_start(); // Start the receiver PLL running

Serial.begin(9600); // serial is used for dubugging purposes only

Serial.print("starting up"); // print starting up to the serial monitor

32

Page 35: Capstone Project Report 2016 final

//enter speech command here to say "timbot online

}

byte ssr[500];//define a character string

void loop()

{ // wait mode

uint8_t buf[VW_MAX_MESSAGE_LEN];

uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it to match the byte length of the sent message.

}

if (x == 6){ // if x is 6 switch the Mode1 pin to HIGH

digitalWrite(Mode1, HIGH);

digitalWrite(Mode2, LOW); //safety precaussion

}

if (x == 7) { //if x is 7 switch the mode2 pin to HIGH

digitalWrite(Mode2, HIGH);

digitalWrite(Mode1, LOW); // safety precaussion

}

while (digitalRead(Sensor) == LOW & digitalRead(Mode1) == LOW & digitalRead(Mode2) == LOW) {

// if the sensor is detecting something and in wait mode

if (Wspeech == 0) {

SpeechSynthesis.buf_init(ssr); //initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"Starting up"); // say greetings, I'm Timbot 53

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while(Wspeech == 0) { // wait for the speech sheild to finish talking

33

Page 36: Capstone Project Report 2016 final

delay(2000); // place a delay to keep it from speaking during startup

Wspeech = 1;

}

}

if (digitalRead(Sensor) == LOW & Wspeech == 1) { // if sensor detects something and Wspeech is 0

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"Greetings, I'M Timboat 53");// say greetings, I'm Timbot 53

SpeechSynthesis.English(ssr,6,".Howdu Udu");// say how do you do

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while(Wspeech == 1) { // wait for the speech sheild to finish talking

delay(6000);

Wspeech = 2; // increment Wspeech

}

}

if (digitalRead(Sensor) == LOW & Wspeech == 2) { // if object detected wait

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"I was cri Atted as A robotics project by students N thE engineering department"); // talks about itself

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while (Wspeech == 2) { // wait for it to finish talking

delay(9000);

Wspeech = 3; // increment Wspeech

}

}

34

Page 37: Capstone Project Report 2016 final

if (digitalRead(Sensor) == LOW & Wspeech == 3) { // if object is detected speak again

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"if U would like to learn About robotics. talk to the engineering department");//

SpeechSynthesis.Espeaking(0,0,4,ssr);//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while(Wspeech == 3) { // wait for the speech sheild to finish talking

delay(10000);

Wspeech = 1; // increment Wspeech

}

}

}

while(digitalRead(Mode1) == HIGH) { // manual mode

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it to match the byte length of the sent message.

}

if (x == 2){

Serial.print("forward"); // used for debugging

digitalWrite(forward, HIGH); //tell the motor to go forward

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(backward, LOW);

}

else if (x == 3){

35

Page 38: Capstone Project Report 2016 final

Serial.print("Backward"); //for debugging

digitalWrite(backward, HIGH); //tell the motor to go reverse

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

else if (x == 4){

Serial.print("left"); // for debuggint

digitalWrite(left, HIGH); //tell the motors tp turn left

digitalWrite(right, LOW);

digitalWrite(backward, LOW);

digitalWrite(forward, LOW);

}

else if (x == 5){

Serial.print("right"); // for debugging

digitalWrite(right, HIGH); //tell the motors to turn right

digitalWrite(backward, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

else {

Serial.print("stop"); // for debugging

digitalWrite(backward, LOW); //tell the motor to stop

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

if (x == 9) { // speech command 1

36

Page 39: Capstone Project Report 2016 final

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"Greetings, I'M Timboat 53");// say greetings, I'm Timbot 53

SpeechSynthesis.English(ssr,6,".Howdu Udu");// say how do you do

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

}

if (x == 10) { //speech command 2

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"I was cri Atted as A graduation project.");//

SpeechSynthesis.English(ssr,6,"by A group of students N the engineering program");//

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

}

if (x == 11) { // speech command 3

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade

SpeechSynthesis.English(ssr,6,"if U would like to learn About robotics talk to the engineering department"); // invites people to look at the engineering table on ap day

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

}

if (x == 8) { // enter wait mode

digitalWrite(Mode1, LOW);

}

Serial.println();

}

37

Page 40: Capstone Project Report 2016 final

/* because this mode is not currently working correctly it has been disabled

while (digitalRead(Mode2) == HIGH) { // Sentry Mode

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it equal to the byte length of sent message.

}

while (digitalRead(Start) == HIGH) { // run autonomusly

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it equal to the byte length of sent data.

}

if (x == 8) { // emergency stop

digitalWrite(Mode2, LOW); // leave sentry mode

digitalWrite(Stop, HIGH); // tell robot to stop

digitalWrite(Start, LOW); // stop movement path

}

if (digitalRead(Sensor) == HIGH) { // reset the stop pin if the sensor is high

digitalWrite(Stop, LOW);

}

while (digitalRead(Sensor) == LOW) { // during sentry mode stop when the sensor pin is low

digitalWrite(Stop, HIGH);

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

38

Page 41: Capstone Project Report 2016 final

int i;

x = buflen; // this is taking the variable 'x' and setting it equal to the byte length of sent data

}

if (x == 8) { // emergency stop

digitalWrite(Mode2, LOW); // leave sentry mode

digitalWrite(Start, LOW); // stop movement path

digitalWrite(Stop, HIGH); // tell robot to stop

}

}

if (x == 10) { // if stop is pushed

digitalWrite(Stop, HIGH); // tell the robot to stop

digitalWrite(Start, LOW); // tell the robot to exit movement loop

}

}

// run this while start is low

if (x == 9) { // tell the robot to drive autonomusly

digitalWrite(Start, HIGH); // begin moving along the saved path

digitalWrite(Stop, LOW); //reset stop pin

}

if (x == 10) { // tells the robot to stop moving

digitalWrite(Start, LOW); // reset the start pin

digitalWrite(Stop, HIGH); // send the signal to stop

delay(1000); // 1 second delay

digitalWrite(Stop, LOW); // reset the stop pin

}

if (x == 4) { // tells the robot to save the current position

digitalWrite(Save, HIGH);

delay(500);

39

Page 42: Capstone Project Report 2016 final

digitalWrite(Save, LOW);

}

if (x == 2){

digitalWrite(forward, HIGH); //tell the motor to go forward

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(backward, LOW);

}

else if (x == 3){

digitalWrite(backward, HIGH); //tell the motor to go reverse

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

else {

digitalWrite(backward, LOW); //tell the motor to stop

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

if (x == 8) { // exit sentry mode

digitalWrite(Mode2, LOW);

}

}*/

}

40

Page 43: Capstone Project Report 2016 final

Right Arduino Uno with RoboClaw

/*the words created by the speech shield can't always be pronounced clearly.

to compinsate for this we are breaking difficult words into smaller words or syllables

and spelling them Phoneticly.

each letter is only able to create two sounds, the lowercase and the uppercase.

this means that sometimes it may be required to play with the spelling to find the correct sound.

*/

#include <SpeechSynthesis.h> // library required to opperate the speech shield

#include <VirtualWire.h> // library required to opperate the RF receiver

int x = 0; // x is the byte size of data receive by the receiver

int Start = 13; // the start command is used to activate autonomus mode

int Stop = 12; // tells the robot to stop autonomus mode

const int receive_pin = 11; // the receiver uses pin 11

int forward = 10; // forward is going to be the name of pin 10

int backward = 9; // backward is the name of pin 9

int right = 8; // right is the name of pin 8

int left = 7; // left is the name of pin 7

int Estop = 6; // tells the motors to stop if the emergency stop is pushed

int Mode2 = 5; // Mode2 is to tell the robot to enter senry mode

int Mode1 = 4; // mode1 is to tell the robot to enter manual mode

int Sensor = 3; // the sensor pin will recieve data from the ultra sonic sensors on the MEGA

int Save = 2; // this will tell the robot to save distance

int Mspeech1 = 0; // manual mode speech 1

int Mspeech2 = 0; // Manual mode speech 2

int Mspeech3 = 0; // manual mode speech 3

41

Page 44: Capstone Project Report 2016 final

int Wspeech = 0; //Wait mode speech

void setup()

{

//set these pins as output pins

pinMode(forward, OUTPUT);

pinMode(backward, OUTPUT);

pinMode(right, OUTPUT);

pinMode(left, OUTPUT);

pinMode(Mode1, OUTPUT);

pinMode(Mode2, OUTPUT);

pinMode(Save, OUTPUT);

pinMode(Start, OUTPUT);

pinMode(Stop, OUTPUT);

pinMode(Estop, OUTPUT);

// set this as an input pin

pinMode(Sensor, INPUT);

// Initialise the IO and ISR

vw_set_rx_pin(receive_pin);

vw_set_ptt_inverted(true); // Required for DR3100

vw_setup(2000); // Bits per sec

vw_rx_start(); // Start the receiver PLL running

Serial.begin(9600); // serial is used for dubugging purposes only

Serial.print("starting up"); // print starting up to the serial monitor

//enter speech command here to say "timbot online

42

Page 45: Capstone Project Report 2016 final

}

byte ssr[500];//define a character string

void loop()

{ // wait mode

uint8_t buf[VW_MAX_MESSAGE_LEN];

uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it to match the byte length of the sent message.

}

if (x == 6){ // if x is 6 switch the Mode1 pin to HIGH

digitalWrite(Mode1, HIGH);

digitalWrite(Mode2, LOW); //safety precaussion

}

if (x == 7) { //if x is 7 switch the mode2 pin to HIGH

digitalWrite(Mode2, HIGH);

digitalWrite(Mode1, LOW); // safety precaussion

}

while (digitalRead(Sensor) == LOW & digitalRead(Mode1) == LOW & digitalRead(Mode2) == LOW) {

// if the sensor is detecting something and in wait mode

if (Wspeech == 0) {

SpeechSynthesis.buf_init(ssr); //initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"Starting up"); // say greetings, I'm Timbot 53

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while(Wspeech == 0) { // wait for the speech sheild to finish talking

delay(2000); // place a delay to keep it from speaking during startup

43

Page 46: Capstone Project Report 2016 final

Wspeech = 1;

}

}

if (digitalRead(Sensor) == LOW & Wspeech == 1) { // if sensor detects something and Wspeech is 0

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"Greetings, I'M Timboat 53");// say greetings, I'm Timbot 53

SpeechSynthesis.English(ssr,6,".Howdu Udu");// say how do you do

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while(Wspeech == 1) { // wait for the speech sheild to finish talking

delay(6000);

Wspeech = 2; // increment Wspeech

}

}

if (digitalRead(Sensor) == LOW & Wspeech == 2) { // if object detected wait

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"I was cri Atted as A robotics project by students N thE engineering department"); // talks about itself

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while (Wspeech == 2) { // wait for it to finish talking

delay(9000);

Wspeech = 3; // increment Wspeech

}

}

if (digitalRead(Sensor) == LOW & Wspeech == 3) { // if object is detected speak again

44

Page 47: Capstone Project Report 2016 final

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"if U would like to learn About robotics. talk to the engineering department");//

SpeechSynthesis.Espeaking(0,0,4,ssr);//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

while(Wspeech == 3) { // wait for the speech sheild to finish talking

delay(10000);

Wspeech = 1; // increment Wspeech

}

}

}

while(digitalRead(Mode1) == HIGH) { // manual mode

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it to match the byte length of the sent message.

}

if (x == 2){

Serial.print("forward"); // used for debugging

digitalWrite(forward, HIGH); //tell the motor to go forward

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(backward, LOW);

}

else if (x == 3){

Serial.print("Backward"); //for debugging

45

Page 48: Capstone Project Report 2016 final

digitalWrite(backward, HIGH); //tell the motor to go reverse

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

else if (x == 4){

Serial.print("left"); // for debuggint

digitalWrite(left, HIGH); //tell the motors tp turn left

digitalWrite(right, LOW);

digitalWrite(backward, LOW);

digitalWrite(forward, LOW);

}

else if (x == 5){

Serial.print("right"); // for debugging

digitalWrite(right, HIGH); //tell the motors to turn right

digitalWrite(backward, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

else {

Serial.print("stop"); // for debugging

digitalWrite(backward, LOW); //tell the motor to stop

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

if (x == 9) { // speech command 1

SpeechSynthesis.buf_init(ssr);//initialize the buff

46

Page 49: Capstone Project Report 2016 final

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"Greetings, I'M Timboat 53");// say greetings, I'm Timbot 53

SpeechSynthesis.English(ssr,6,".Howdu Udu");// say how do you do

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

}

if (x == 10) { //speech command 2

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade 5

SpeechSynthesis.English(ssr,6,"I was cri Atted as A graduation project.");//

SpeechSynthesis.English(ssr,6,"by A group of students N the engineering program");//

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

}

if (x == 11) { // speech command 3

SpeechSynthesis.buf_init(ssr);//initialize the buff

SpeechSynthesis.English(ssr,4,"5");//volume in grade

SpeechSynthesis.English(ssr,6,"if U would like to learn About robotics talk to the engineering department"); // invites people to look at the engineering table on ap day

SpeechSynthesis.Espeaking(0,0,4,ssr);

//Executive commands above, "0" is synthesis command; "0" select voice; "4" speech function

}

if (x == 8) { // enter wait mode

digitalWrite(Mode1, LOW);

}

Serial.println();

}

/* because this mode is not currently working correctly it has been disabled

47

Page 50: Capstone Project Report 2016 final

while (digitalRead(Mode2) == HIGH) { // Sentry Mode

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it equal to the byte length of sent message.

}

while (digitalRead(Start) == HIGH) { // run autonomusly

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

x = buflen; // this is taking the variable 'x' and setting it equal to the byte length of sent data.

}

if (x == 8) { // emergency stop

digitalWrite(Mode2, LOW); // leave sentry mode

digitalWrite(Stop, HIGH); // tell robot to stop

digitalWrite(Start, LOW); // stop movement path

}

if (digitalRead(Sensor) == HIGH) { // reset the stop pin if the sensor is high

digitalWrite(Stop, LOW);

}

while (digitalRead(Sensor) == LOW) { // during sentry mode stop when the sensor pin is low

digitalWrite(Stop, HIGH);

uint8_t buf[VW_MAX_MESSAGE_LEN]; // buf is the message recieved

uint8_t buflen = VW_MAX_MESSAGE_LEN; // buflen is the number of bytes the message is

if (vw_get_message(buf, &buflen)) { // Non-blocking

int i;

48

Page 51: Capstone Project Report 2016 final

x = buflen; // this is taking the variable 'x' and setting it equal to the byte length of sent data

}

if (x == 8) { // emergency stop

digitalWrite(Mode2, LOW); // leave sentry mode

digitalWrite(Start, LOW); // stop movement path

digitalWrite(Stop, HIGH); // tell robot to stop

}

}

if (x == 10) { // if stop is pushed

digitalWrite(Stop, HIGH); // tell the robot to stop

digitalWrite(Start, LOW); // tell the robot to exit movement loop

}

}

// run this while start is low

if (x == 9) { // tell the robot to drive autonomusly

digitalWrite(Start, HIGH); // begin moving along the saved path

digitalWrite(Stop, LOW); //reset stop pin

}

if (x == 10) { // tells the robot to stop moving

digitalWrite(Start, LOW); // reset the start pin

digitalWrite(Stop, HIGH); // send the signal to stop

delay(1000); // 1 second delay

digitalWrite(Stop, LOW); // reset the stop pin

}

if (x == 4) { // tells the robot to save the current position

digitalWrite(Save, HIGH);

delay(500);

digitalWrite(Save, LOW);

49

Page 52: Capstone Project Report 2016 final

}

if (x == 2){

digitalWrite(forward, HIGH); //tell the motor to go forward

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(backward, LOW);

}

else if (x == 3){

digitalWrite(backward, HIGH); //tell the motor to go reverse

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

else {

digitalWrite(backward, LOW); //tell the motor to stop

digitalWrite(right, LOW);

digitalWrite(left, LOW);

digitalWrite(forward, LOW);

}

if (x == 8) { // exit sentry mode

digitalWrite(Mode2, LOW);

}

}*/

}

50

Page 53: Capstone Project Report 2016 final

Remote Control Transmitter Code

// include the library code:

#include <Wire.h>

#include <Adafruit_RGBLCDShield.h>

#include <utility/Adafruit_MCP23017.h>

// Module KY023

// For more info see http://tkkrlab.nl/wiki/Arduino_KY-023_XY-axis_joystick_module

int JoyStick_X = A0; // x

int JoyStick_Y = A1; // y

int JoyStick_Z = 4; // key

#include <VirtualWire.h>

const int led_pin = 11;

const int transmit_pin = 12;

const int receive_pin = 2;

const int transmit_en_pin = 3;

int Estop = 5; // Estop is the emergency stop in sentry mode and the speed adjustment in manual mode

int command = 8;

/* the variable command will be used to change the message that is sent to the robot. the messages will be commands */

int Start = 0; // used to toggle start in sentry mode

int Stop = 0; // used to toggle stop in sentry mode

// The shield uses the I2C SCL and SDA pins. On classic Arduinos

// this is Analog 4 and 5 so you can't use those for analogRead() anymore

// However, you can connect other I2C sensors to the I2C bus and share

// the I2C bus.

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color

#define RED 0x1

51

Page 54: Capstone Project Report 2016 final

#define YELLOW 0x3

#define GREEN 0x2

#define TEAL 0x6

#define BLUE 0x4

#define VIOLET 0x5

#define WHITE 0x7

int Mode = 0;

/* this is to determine which mode the robot is in 0 = startup or neutral, 1 = teach mode, 2 = manuel mode */

int Select = 0;

/* this is used to confirm the mode. nothing will happen until the mode has been set and the select button has been pressed to confirm the selection 0 = false meaning a mode has not been selected and 1 = true meaning the a mode has been selected */

// Saying 1,2&3 are used to select which speech option you want the robot to say

int Saying1 = 0;

int Saying2 = 0;

int Saying3 = 0;

void setup() {

Serial.begin(9600); // Debugging output

lcd.begin(16, 2); // set up the LCD's number of columns and rows:

lcd.print("Starting up"); // a start up message so that you know that it is on

lcd.setBacklight(WHITE); //set the backlight color to white

delay(1500); //1.5 second delay

lcd.clear(); // clear lcd screen

lcd.print("Select an"); //print message

lcd.setCursor(0,1); //write on the second line of the lcd screen

lcd.print("Opperation"); // print message

pinMode (JoyStick_X, INPUT);

pinMode (JoyStick_Y, INPUT);

52

Page 55: Capstone Project Report 2016 final

pinMode (JoyStick_Z, INPUT_PULLUP);

pinMode (Estop, INPUT); // reads wether it is high or low

// Initialise the IO and ISR

vw_set_tx_pin(transmit_pin);

vw_set_rx_pin(receive_pin);

vw_set_ptt_pin(transmit_en_pin);

vw_set_ptt_inverted(true); // Required for DR3100

vw_setup(2000); // Bits per sec

}

uint8_t i=0;

byte count = 1;

void loop() {

uint8_t buttons = lcd.readButtons();

if (buttons) { //if a button is pushed first clear the screan

lcd.clear();

lcd.setCursor(0,0); //write on the first line of the lcd screen

if (buttons & BUTTON_UP) { // this is used as a mode select button

lcd.print("Sentry Mode "); // tells you which mode you've selected

lcd.setBacklight(TEAL);

// this color is so that you will have another way of knowing which mode you are in

Mode = 1; //set mode to = 1

Select = 0;

// this is so that the system will not change modes if you push select before selecting mode

}

if (buttons & BUTTON_RIGHT) { // this is the second mode button

lcd.print("Manual Mode");

lcd.setBacklight(VIOLET); // this color will be associated with manuel mode

Mode = 2; //set the mode = 2

53

Page 56: Capstone Project Report 2016 final

Select = 0;

// this is so that the system will not change modes if you push select before selecting mode

}

if (buttons & BUTTON_SELECT) {

lcd.clear(); //clear lcd screen

Select = 1; // set select to = 1

delay(400); // .4 second delay

}

while(Mode == 1 & Select == 1) { //sentry mode

if (command == 8){

command = 7; // command 7 tells the robot to enter sentry mode

lcd.clear();

lcd.setCursor(0,0); //write on the first line of the lcd screen

lcd.print("move to");

lcd.setCursor(0,1);

lcd.print("position ");

Start = 0; // reset Start

Stop = 0; // reset Stop

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(led_pin, LOW);

delay(10);

command = 1; // reset command

}

int x,y,z; // set x,y and z as integers

54

Page 57: Capstone Project Report 2016 final

x = analogRead (JoyStick_X); //read x input

y = analogRead (JoyStick_Y); //read y input

uint8_t buttons = lcd.readButtons(); // tells the controller to read the button inputs

if (buttons & BUTTON_SELECT) {

lcd.clear();

lcd.setBacklight(TEAL);

lcd.setCursor(0,0);

lcd.print("position");

lcd.setCursor(0,1);

lcd.print("saved");

delay(1000);

command = 4; //tell the robot to save the position

lcd.clear();

}

if (y >= 600 & x <= 400 & x >= 300) {

Serial.print("move up");

command = 2; // set command equal to 2

Start = 0; // reset start when moving

Stop = 0; // reset Stop

}

if (y <= 50 & x <= 400 & x >= 300) {

Serial.print("move down");

command = 3; // set command equal to 3

Start = 0; // reset start when moving

Stop = 0; //reset stop

}

if (buttons & BUTTON_LEFT) { // tell the robot to start moving

lcd.clear();

55

Page 58: Capstone Project Report 2016 final

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.setBacklight(GREEN); //change the backlight to green

lcd.print("start");

delay(1000);

Start = 1; // set start to 1

Stop = 0; // reset stop

}

if (buttons & BUTTON_DOWN & Stop == 0) { // tell the robot to stop moving

lcd.clear();

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.setBacklight(RED); //change the backlight to green

lcd.print("stop");

delay(500);

Stop = 1;

Start = 0; // reset Start

}

while (Start == 1) { // require the user to push start twice to confirm the command

uint8_t buttons = lcd.readButtons(); // tells the controller to read the button inputs

if (buttons & BUTTON_SELECT & Start == 1 & Stop != 1) {

lcd.clear();

lcd.print("starting"); // writes starting to the lcd screen

delay(500);

command = 9;

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

56

Page 59: Capstone Project Report 2016 final

digitalWrite(led_pin, LOW);

delay(10);

command = 1; // reset command

lcd.clear();

lcd.print("Running"); // tells the user that the robot is running

}

if (buttons & BUTTON_DOWN) { // tell the robot to stop moving

lcd.clear();

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.setBacklight(RED); //change the backlight to green

lcd.print("stop");

delay(500);

Stop = 1;

}

/*if (digitalRead(Estop) == HIGH) {

command = 8; // tell the robot to exit sentry mode immediatly

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(led_pin, LOW);

delay(10);

Mode = 0; // exit sentry mode immediatly

Start = 0; // exit the autonomus loop

lcd.print("shutting down");

delay(1000); // 1 second delay

lcd.clear(); // clear the lcd screen

57

Page 60: Capstone Project Report 2016 final

lcd.setBacklight(WHITE); //set the backlight color to white

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.print("Select an"); // write "Select"

lcd.setCursor(0,1); // write on the second line of the lcd screen

lcd.print("Operation"); // write "Operation"

} */

if (buttons & BUTTON_SELECT & Stop == 1) {

// require the user to push stop twice to confirm the command

lcd.clear();

lcd.print("stoping");

command = 10;

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(led_pin, LOW);

delay(1000);

command = 1; // to keep for resending the command

Start = 0; // reset start

lcd.clear(); // reset the lcd screen

lcd.setBacklight(TEAL); //set the backlight color to white

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.print("Standing by"); // write "Select"

}

}

/*if (digitalRead(Estop) == HIGH) { //stop immediatly when this button is pushed

command = 8; // tell the robot to exit sentry mode immediatly

58

Page 61: Capstone Project Report 2016 final

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(led_pin, LOW);

delay(10);

Mode = 0; // exit sentry mode immediatly

lcd.print("shutting down");

delay(1000); // 1 second delay

lcd.clear(); // clear the lcd screen

lcd.setBacklight(WHITE); //set the backlight color to white

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.print("Select an"); // write "Select"

lcd.setCursor(0,1); // write on the second line of the lcd screen

lcd.print("Operation"); // write "Operation"

}*/

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(led_pin, LOW);

delay(10);

command = 1; // this is reseting command so that opperations will not be repeated accidentally

if ( buttons & BUTTON_UP) {

Mode = 0; // set mode to zero. exiting the current mode

lcd.clear(); // clear the lcd screen

59

Page 62: Capstone Project Report 2016 final

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.print("Exiting"); // write "exiting"

lcd.setCursor(0,1); // write on the second line of the lcd screen

lcd.print("Sentry mode"); // write "sentry mode"

char msg[7] = {5}; // the message that is being sent

digitalWrite(led_pin, HIGH); // Flash a light to show transmitting

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

digitalWrite(led_pin, LOW);

delay(1500); // 1.5 second delay

lcd.clear(); //clear lcd screen

command = 8; // set command = 8 this is to tell the robot to enter wait mode

lcd.setBacklight(WHITE); //set the backlight color to white

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.print("Select an"); // write "Select"

lcd.setCursor(0,1); // write on the second line of the lcd screen

lcd.print("Operation"); // write "Operation"

}

}

while(Mode == 2 & Select == 1) { //manual mode

uint8_t buttons = lcd.readButtons();

int x, y, z;

x = analogRead (JoyStick_X);

y = analogRead (JoyStick_Y);

z = digitalRead (JoyStick_Z);

if (command == 8) {

command = 6; // tell the robot to enter manual mode

60

Page 63: Capstone Project Report 2016 final

char msg[7] = {5}; // the message that is being sent

vw_send((uint8_t *)msg, command); // sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

delay(10);

command = 1; // set command to one so that command operations are not repeated accidentally

// so that it only prints this the first time

lcd.setCursor(0,0); // print on the first line of the lcd screen

lcd.print("Manual Control"); //print "manual control" on the lcd screen

lcd.setCursor(0,1); // print on the second line of the lcd screen

lcd.print("Activated"); // print "activated" on the lcd screen

}

if (y >= 600 & x <= 400 & x >= 300) {

Serial.print("move up");

command = 2; // set command equal to 2

}

if (y <= 50 & x <= 400 & x >= 300) {

Serial.print("move down");

command = 3; // set command equal to 3

}

if (x <= 50 & y <= 400 & y >= 300) {

Serial.print("move left");

command = 4; // set command equal to 4

}

if(x >= 600 & y <= 400 & y >= 300) {

Serial.print("move right");

command = 5; // set command equal to 5

}

61

Page 64: Capstone Project Report 2016 final

if (buttons & BUTTON_UP) {

Saying1 = 1; // set saying1 = 1 and reset the others

Saying2 = 0;

Saying3 = 0;

lcd.clear(); // clear the lcd screen

lcd.setCursor(0,0); // write on the first line

lcd.print("Robot Speech 1"); // tells the user which speech option he has selected

lcd.setCursor(0,1); // write ont the second line

lcd.print("greeting"); // tell the user what the robot will say

delay(100); // delay for 100 miliseconds

}

if (buttons & BUTTON_LEFT) {

Saying1 = 0;

Saying2 = 1; // set saying2 = 1 and reset the others

Saying3 = 0;

lcd.clear(); // clear the lcd screen

lcd.setCursor(0,0); // write on the first line

lcd.print("Robot Speech 2"); // tells the user which speech option he has selected

lcd.setCursor(0,1); // write ont the second line

lcd.print("Introduction"); // tell the user what the robot will say

delay(100); // delay for 100 miliseconds

}

if (buttons & BUTTON_DOWN) {

Saying1 = 0;

Saying2 = 0;

Saying3 = 1; // set saying3 = 1 and reset the others

lcd.clear(); // clear the lcd screen

lcd.setCursor(0,0); // write on the first line

62

Page 65: Capstone Project Report 2016 final

lcd.print("Robot Speech 3"); // tells the user which speech option he has selected

lcd.setCursor(0,1); // write ont the second line

lcd.print("Move Please"); // tell the user what the robot will say

delay(100); // delay for 100 miliseconds

}

if (buttons & BUTTON_SELECT) { // select button is used to confirm button commands

if (Saying1 == 1) {

command = 9; // tell the robot to say the first speech option

}

else if (Saying2 == 1) {

command = 10; // tell the robot to say the second speech option

}

else if (Saying3 == 1) {

command = 11; // tell the robot to say the third speech option

}

Saying1 = 0; //reset so that the command is not repeated by accident

Saying2 = 0; //reset so that the command is not repeated by accident

Saying3 = 0; //reset so that the command is not repeated by accident

lcd.clear(); // clear the lcd screen

lcd.setCursor(0,0); // print on the first line of the lcd screen

lcd.print("Manual Control"); //print "manual control" on the lcd screen

lcd.setCursor(0,1); // print on the second line of the lcd screen

lcd.print("Activated"); // print "activated" on the lcd screen

}

Serial.println(); //go to the next line of the serial monitor

char msg[7] = {5}; // the message that is being sent

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

63

Page 66: Capstone Project Report 2016 final

vw_wait_tx(); // Wait until the whole message is gone

delay(10);

command = 1;

// set command to one so that command operations are not repeated accidentally

if (buttons & BUTTON_RIGHT) { //exit manual mode

Mode = 0;

command = 8; //set command = 8 THIS is the reset mode command

lcd.clear();

lcd.setCursor(0,0);

lcd.print("Exiting");

lcd.setCursor(0,1);

lcd.print("Manual Mode");

char msg[7] = {5}; // the message that is being sent

vw_send((uint8_t *)msg, command);

// sends a message and tells the reciever how many bytes of data the message is

vw_wait_tx(); // Wait until the whole message is gone

delay(10); // 10 milisecond delay

delay(1500); // 1.5 second delay

lcd.clear();

lcd.setBacklight(WHITE); //set the backlight color to white

lcd.setCursor(0,0); // write on the first line of the lcd screen

lcd.print("Select an"); // write "Select"

lcd.setCursor(0,1); // write on the second line of the lcd screen

lcd.print("Operation"); // write "Operation"

}

}

}

}

64