09 December 2019

Final Project: SafePhone


There are, on average, more distracted driving accidents that occur that lead to death in the United States than any other type of accident occurrences. According to the Federal Communications Commission (FCC), nine people are killed and 1,000 are injured in distracted driving related accidents every day in the United States.

For my final project, I made a game that will encourage drivers to leave their phones in the cell phone holder while they drive. (Note: My original idea included an LCD Display but while working with it, it decided to stop working.)

 If the driver stays at least 21 cm away from the device, they will receive 1 point every 10 seconds but if they get within 19 cm of the phone, the program will deduct 10 points from their total point value.

The hall effect sensor detects if there is a magnet present and the Sharp IR sensor detects if the driver gets close to the cell phone.
The idea is for the driver to be able to claim social media credit with their friends and help them become aware of their role in safe driving.

Materials:                                                                                           Programs:
Car Phone Holder                                                                               Tinkercad
Arduino Mega 2560                                                                            Arduino
Arduino Mega 2560 Case                                                                   Ultimaker Cura 4.4
3-D Printed Cable Box
3-D Printed Hall Effect Sensor Box
Apple Barrel Black Paint
Hot Glue
Jumper Wires
Hall Effect Sensor
Sharp IR Sensor




 





// Include the library:
#include <SharpIR.h>
// Define model and input pin:
#define IRPin A0
//#define model GP2Y0A21YK0F
unsigned long time; //Time Value.
// Create variable to store the distance:
int distance_cm;
/* Model :
GP2Y0A02YK0F --> 20150
GP2Y0A21YK0F --> 1080
GP2Y0A710K0F --> 100500
GP2YA41SK0F --> 430
*/
int SENSOR = A2 ; // define the Hall magnetic sensor
int pointVal = 0 ; // this is the point value.
// Create a new instance of the SharpIR class:
//SharpIR irSensor = SharpIR("GP2Y0A21YK0F", IRPin);
SharpIR irSensor(SharpIR::GP2Y0A21YK0F, A0);
int val ; //define numeric variables
int points = 0;
void setup() {
pinMode (SENSOR, INPUT) ; // define the Hall magnetic sensor line as input
// Begin serial communication at a baudrate of 9600:
Serial.begin(9600);
}
void loop() {
// Get a distance measurement and store it as distance_cm:
distance_cm = irSensor.getDistance();
// Print the measured distance to the serial monitor:
Serial.print("Mean distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
Serial.println("\n");
Serial.print ("Time: ");
time = millis();
Serial.println(time);//prints time since program has started
delay(1000);
Serial.println("\n");
val = analogRead (SENSOR) ; // read sensor line
Serial.println("hal: ");
Serial.println(val);
if(distance_cm < 10 && distance_cm > 18){
Serial.print ("danger zone");
}
Serial.println("\n");
if(distance_cm < 19) {
points -= 10;
Serial.print ("Point Value");
Serial.println(pointVal);
}
Serial.println("\n");
if(distance_cm > 21) {
points ++;
Serial.print ("Point Value");
Serial.println(pointVal);
}
Serial.print("points: ");
Serial.println(points);
Serial.println("\n");
}
view raw Final Project hosted with ❤ by GitHub

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.