32
Texting & Driving Prevention: Final Report Team members: Alexander Myrah (Group Leader) Chinyere William Udoh Zhenzhen (Sunny) Song Xiaotian (David) Xu

iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Texting & Driving Prevention: Final Report

Team members:

Alexander Myrah (Group Leader)

Chinyere William Udoh

Zhenzhen (Sunny) Song

Xiaotian (David) Xu

EENG-491-W02

Professors: Dr. Tao Zhang and Dr. Michael Colef

Spring 2014

Page 2: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Introduction:

The National Safety Council (NSC) estimates that 1.6 million phone related car crashes

happen each year in the US. With smartphone use becoming more common each year, it is

imperative to ensure that people are not misusing the technology and are educated of all the

dangers of texting while driving.

Currently Available Products:

There are products currently on the market which can be used to prevent texting while

driving. The problem with these devices are that they are all aftermarket devices. The people

who are most likely to get into car crashes are between the ages of 16 and 24 (cdc.gov). These

are not the types of people who are going to go out of their ways to purchase and install these

devices. A product which comes standard in cars is needed to ensure the safety of the youth of

this country. Another problem with the currently available products are that they are expensive

and require time to install them. One product, the SCOSCHE cellCONTROL Safe Driving

System for Cell Phones costs around $130. Another system called the Safe Driving Systems

KEY2SAFEDRIVING ODB II costs around $30. A third product is made by esurance, but it is

only for people who have esurance auto insurance. These products all work by not allowing the

driver to use their phones through means other than hands free communication. Another device is

the OrigoSafe Ignition Interlock System. This system costs $274 for hardware and an additional

$125 installation fee. This system will not allow the car to turn on unless the phone is put in the

“locked case”.

Goals:

Page 3: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Our goal is to achieve a simple and convenient way for drivers to drive safely by not being

tempted to use their phones while driving. Our product is designed to be installed standard in

cars. When an individual purchases a new car, the system will already be installed in the car. All

that will be required is that the driver registers their phone when they first enter the car. At that

point, the device will search for the drivers phone when the car is unlocked.

List of Parts:

(1) Arduino Mega ADK,

(1) Bluetooth Modem--BlueSMiRF Gold

(3) HC-SR04 Ranging Detector Mod Distance Sensor

Wall Adapter Power Supply

Breadboard

Printer cable

Two LEDs (1 Red, 1 Green)

Two 51.2Ω Resistors

One CEM-1203(42) Buzzer

Arduino programming software

Android Phone(s)

Functionality:

Our project is set up to work on a car without being mounted to the car for now. On the

breadboard, the three HC-SR04 distance sensors are connected next to each other and being

wired to different pins on the Arduino board. Their functionality is outlined in the code in

Page 4: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix D of this report. The driver’s distance sensor determines the functioning of the green

and red LEDs. If the driver is within a certain distance of the sensor, the red LED will turn on.

Otherwise, the green LED will be on. The buzzer is connected to the second two distance

sensors. These sensors represent the front and back bumpers of the car. If there is an object

detected too close to the car, the buzzer will beep to warn the driver of the impending danger.

There are three apps which work with our code. The first one is Amarino. This code can

be used to connect to the BlueSMiRF Bluetooth module and display the distances between the

three sensors and nearby objects. Another app called SensorGraph, which uses the Amarino to

connect to the Bluetooth module, graphs the averages of the three distances between the sensors

and nearby objects. The third app which can be used with our project is BlueTerm. This app also

displays the distances between the sensors and nearby objects. It displays some extra data due to

the Amarino library, since our device was programmed to work primarily with Amarino.

Hardware Setup

Page 5: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

BlueTerm App

Amarino App Monitoring

Page 6: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car
Page 7: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Data Processing/Communication:

This project communicates with a Samsung Galaxy S4 Android Phone via Bluetooth

Communication. The BlueSMiRF Bluetooth module is connected directly to the Arduino Mega

ADK through a breadboard and is programmed to display information regarding the three

distance sensors.

Future Plans:

For future development of our project, there are a number of steps we can take to make our

product more marketable. Our first step can be editing the source code of the BlueTerm app to

turn off the phone screen when a person is detected. The second step we can take is building

mounting brackets to attach two of the distance sensors to the front and back bumpers of the car

and connecting a power supply to the car and device. The last update we can make is making a

smaller microcontroller to make our project smaller, cheaper, and more functional.

Conclusion:

This project was a success. We were able to integrate three distance sensors, a buzzer, two

LEDs, and a Bluetooth module to a breadboard and have them communicate with an Android

Phone via Bluetooth. This project is compatible with three open source apps. BlueTerm displays

the distances on the distance sensors. Amarino also displays the distances on the distance

sensors. SensorGraph uses the Amarino App to display a graph averaging the values of the three

sensors.

SensorGraph App Screen

Page 8: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix A: Hardware Design

Page 9: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix B: Software Design

Page 10: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix C: Wiring Diagram

Page 11: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix D: Arduino Code

Page 12: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

#include <MeetAndroid.h>

/*

Programmers: Alexander Myrah, Chinyere Udoh, Xiaotan (David) Xu, Zhenzhen (Sunny) Song

Date of Last Edit: 5/5/14

EENG 491 Texting and Driving Prevention Project

Original code improvements to the Ping sketch sourced from Trollmaker.com

Some code and wiring inspired by http://en.wikiversity.org/wiki/User:Dstaub/robotcar

Amarino portion inspired from http://www.amarino-toolkit.net/index.php/download.html

Buzzer portion inspired by http://www.instructables.com/id/Play-the-French-Can-Can-Using-an-

Arduino-and-Buzze/?ALLSTEPS

*/

#define trigPin 13 // Trig pin on HC-SR04 (Driver Seat)

#define echoPin 12 //Echo pin on HC-SR04 (Driver Seat)

#define trigPin1 7 // Trig pin on second HC-SR04 (Front Bumper)

#define echoPin1 6 // Echo pin on second HC-SR04 (Front Bumper)

#define trigPin2 5 // Trig pin on third HC-SR04 (Back Bumper)

#define echoPin2 4 // Echo pin on third HC-SR04 (Back Bumper)

#define led 11 // Red LED

#define led2 10 // Green LED

Page 13: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

MeetAndroid meetAndroid; // Amarino Variable

//int sensor = A5;

int distance;

long duration;

int distance1;

long duration1;

int distance2;

long duration2;

int buzzer=9;

void setup() {

Serial.begin(57600); //57600 Baud Rate

pinMode(trigPin, OUTPUT); // Output signal is the trig pin on HC-SR04 (Driver)

pinMode(echoPin, INPUT); // Input signal is the echo pin on HC-SR04 (Driver)

pinMode(trigPin1, OUTPUT); // Output signal is the trig pin on HC-SR04 (Front Bumper)

pinMode(echoPin1, INPUT); // Input signal is the echo pin on HC-SR04 (Front Bumper)

pinMode(trigPin2, OUTPUT); // Output signal is the trig pin on HC-SR04 (Back Bumper)

pinMode(echoPin2, INPUT); // Input signal is the echo pin on HC-SR04 (Back Bumper)

pinMode(led, OUTPUT); // Red LED is an output

pinMode(led2, OUTPUT); // Green LED is an output

pinMode(buzzer, OUTPUT); // Set a pin for buzzer output

}

void loop() {

Page 14: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

// Add a delay to prevent an overload on the phone side

delay(50);

distance = s();

delay(50);

distance1 = s1();

delay(50);

distance2 = s2();

if (distance1 < 10 ||distance2 < 10 ) // Bumper object detected case

{

// This is where the Buzzer On/Off happens

buzz(9, 2500, 500);

}

else if (distance < 30) // Driver in car case

{

digitalWrite(led,HIGH); // When the Red condition is met, the Red LED should turn on

digitalWrite(led2,LOW); // If the Red LED is on, the Green LED should be off.

}

else if (distance > 30) // Driver not in car case

{

Page 15: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

digitalWrite(led,LOW); // When the Green condition is met, the Green LED should turn on

digitalWrite(led2,HIGH); // If the Green LED is on, the Red LED should be off.

}

if (distance >= 200 || distance <= 0) // Driver Out of Range Case

{

//Above 200cm or Below 0cm is out of the range of the sensor

Serial.print("Out of range");

Serial.print(" Front Bumper: ");

Serial.print(distance1); //Display the distance on the phone

Serial.print(" cm ");

Serial.print(" Back Bumper: ");

Serial.print(distance2); //Display the distance on the phone

Serial.println(" cm ");

}

else if (distance1 >= 200 || distance1 <= 0) // Front Bumper Out of Range Case

{

Serial.print(" Driver: ");

Serial.print(distance); //Display the distance on the phone

Serial.print(" cm ");

Serial.print(" Front Bumper: ");

Serial.print(distance1); //Display the distance on the phone

Serial.print(" cm ");

Page 16: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Serial.println("Out of range");

}

else if (distance2 >= 200 || distance2 <= 0) // Back Bumper Out of Range Case

{

Serial.print(" Driver: ");

Serial.print(distance); //Display the distance on the phone

Serial.print(" cm ");

Serial.print("Out of range");

Serial.print(" Back BuBumperper: ");

Serial.print(distance2); //Display the distance on the phone

Serial.println(" cm ");

}

else if ((distance >= 200 || distance <= 0) && (distance1 >= 200 || distance1 <=0 )) // Driver and

Front Bumper Out of Range Case

{

Serial.print(" Out of range ");

Serial.print(" Out of range ");

Serial.print(" Back Bumper: ");

Serial.print(distance2); //Display the distance on the phone

Serial.println(" cm ");

}

else if ((distance >= 200 || distance <= 0) && (distance2 >= 200 || distance2 <=0 )) // Driver and

Page 17: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Back Bumper Out of Range Case

{

Serial.print(" Out of range ");

Serial.print(" Front Bumper: ");

Serial.print(distance1); //Display the distance on the phone

Serial.print(" cm ");

Serial.print(" Out of range ");

}

else if ((distance1 >= 200 || distance1 <= 0) && (distance2 >= 200 || distance2 <=0 )) // Front

and Back Bumper Out of Range Case

{

Serial.print(" Driver: ");

Serial.print(distance); //Display the distance on the phone

Serial.print(" cm ");

Serial.print(" Out of range ");

Serial.print(" Out of range ");

}

else if ((distance >= 200 || distance <= 0)&&(distance1 >= 200 || distance1 <= 0) && (distance2

>= 200 || distance2 <=0 )) // Out of Range Case

{

Serial.print(" Out of range ");

Page 18: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Serial.print(" Out of range ");

Serial.print(" Out of range ");

}

else {

Serial.print(" Driver: ");

Serial.print(distance); //Display the distance on the phone

Serial.print(" cm ");

Serial.print(" Front Bumper: ");

Serial.print(distance1); //Display the distance on the phone

Serial.print(" cm ");

Serial.print(" Back Bumper: ");

Serial.print(distance2); //Display the distance on the phone

Serial.println(" cm ");

meetAndroid.receive(); // you need to keep this in your loop() to receive events

meetAndroid.send(analogRead(trigPin)); // Read the output from the Driver's HC-SR04

meetAndroid.receive();

meetAndroid.send(analogRead(trigPin1)); // Read the output from the Front Bumpers HC-SR04

meetAndroid.receive();

meetAndroid.send(analogRead(trigPin2)); // Read the output from the Back Bumpers HC-SR04

Page 19: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

}

delay(500);

}

//Programming the functionaity of the buzzer

void buzz(int targetPin, long frequency, long length) {

long delayValue = 1000000/frequency/2; // Calculates the delay value between transitions

//// 1 second's worth of microseconds, divided by the frequency, then split in half since

//// there are two phases to each cycle

long numCycles = frequency * length/ 1000; // Calculates the number of cycles for proper

timing

//// multiply frequency, which is really cycles per second, by the number of seconds to

//// get the total number of cycles to produce

for (long i=0; i < numCycles; i++){ // for the calculated length of time...

digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram

delayMicroseconds(delayValue); // wait for the calculated delay value

digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram

delayMicroseconds(delayValue); // wait againf or the calculated delay value

}

}

//Algorithms to display the correct distance for the three HC-SR04 distance sensors

int s(){

Page 20: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

long duration3 = pulseIn(echoPin, HIGH);

int distance3 = (duration3/2) / 29.1;

return distance3;

}

int s1(){

digitalWrite(trigPin1, LOW);

delayMicroseconds(2);

digitalWrite(trigPin1, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin1, LOW);

long duration4 = pulseIn(echoPin1, HIGH);

int distance4 = (duration4/2) / 29.1;

return distance4;

}

Page 21: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

int s2(){

digitalWrite(trigPin2, LOW);

delayMicroseconds(2);

digitalWrite(trigPin2, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin2, LOW);

long duration5 = pulseIn(echoPin2, HIGH);

int distance5 = (duration5/2) / 29.1;

return distance5;

}

Page 22: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix E: Android Code

1. The Blueterm source code can be found at the following website:

http://pymasde.es/blueterm/

2. Additional information about the Amarino and SensorGraph apps can be found at

https://code.google.com/p/amarino/

Page 23: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car
Page 24: iris.nyit.eduiris.nyit.edu/.../prj_reports/spring2014/project1.docx · Web viewArduino programming software Android Phone(s) Functionality: Our project is set up to work on a car

Appendix F: References

1. Original code improvements to the Ping sketch sourced from Trollmaker.com

2. Some code and wiring inspired by http://en.wikiversity.org/wiki/User:Dstaub/robotcar

3. Amarino portion inspired from http://www.amarino-toolkit.net/index.php/download.html

4. Buzzer portion inspired by http://www.instructables.com/id/Play-the-French-Can-Can-Using-

an-Arduino-and-Buzze/?ALLSTEPS