## Inspiration

We, as all students do, frequently and unwillingly fall to the powers of procrastination. This invention is for when the little cute Pomodoro and Screen Time reminders are a tad too easy to ignore.

## What it does

The device sits in a predetermined area that you would not want to be in order to focus. For example beside your bed, on the couch, in front of your gaming PC/console. If it detects a person there, It will aim at you and fire projectiles.

## How we built it

We built it by integrating a variety of technologies. Firstly, in terms of the frontend, it works with with an Android app developed using the Qualcomm HDK 8450 which has autonomous controls such as connecting to the projectile gun, turning on and off. The app also takes care of the ML Computer Vision needed in order to both detect people and where they are via Google's ML Kit. This then sends this information wirelessly via Bluetooth to an Arduino which is hooked up to two motors that control the aiming and firing of the projectile. The angle at which the projectile launcher turns is approximated with the user sitting 50-100cm away.

## Challenges we ran into

We ran into multiple challenges during the project. Firstly, none of us had any experience developing an Android app and using an HDK8450, so we had a lot of ground to make up in order to start developing the app. Secondly, we found the Bluetooth module connection to be quite difficult to get working, as the official documentation seemed to be quite limited especially for beginners to Android development.

## Accomplishments that we're proud of

One thing we are extremely proud of is the number of different systems and devices we got working together smoothly. From Computer Vision, to Bluetooth Protocols, to Arduino Programming and Mechanical Design, this project brought together a whole variety of fields, and we are proud to have been able to cover all of those bases as smoothly as we did.

## What we learned

As beginners to Android development, we gained a plethora of knowledge on how to build, develop and deploy a working Android application. We also gained experience working with Arduinos, especially involving the communication aspects including sending and receiving information via Bluetooth. Finally we learned about deploying a working ML model in a solution of our own.

## What's next for Failure Management 101

We would like to add movement by putting the whole mechanism on wheels to allow it a greater degree of freedom. We also had plans for voice control, as well as plans for the robot to have access to your laptop in order to determine whether the user is on non-productive websites. Finally, in a from a more realistic and practical purpose, we could envision robots like these helping in patrolling/guard duty as an aid to policemen, although perhaps not firing paper projectiles anymore.
## Inspiration: Home security systems are very expensive and sometimes do not function as intended. Sometimes something simple may happen such as you forgetting the lights on at home or there may be something more drastic such as a large temperature change or even intruder. Our solution aims to be a cheap alert system that would detect three parameters and offer an alert to the user.

## What it does: Our project detects light, temperature and sounds and sends the necessary message to the user. Light sensors would be use to tell the user if they forgot their lights on and hence send an alert to the user. Temperature detection would be use to send drastic changes in temperature or sound to the user as alert messages which may include extreme cold in winter or extreme heat in summer. Sound detection would be used as a security system as it is configured to send alerts to the user once a certain decibel level is reached. Therefore very loud sounds such as breaking glass, shouting or even a gunshot may be detected and an alert sent to the user. These messages are all sent to the user's phone. If anything is wrong, there is a circuit with a red LED light that lights up whenever there is a situation. If the LED is off, the user gets no messages and everything is okay at home. Our project also associates user friendly colors with conditions for example heat is red and cold would be blue.

## How we built it: We used an Arduino as well as a Grove Kit in order to obtain sensors. These sensors were connected to the Arduino and we also attached a breadboard that would receive an input from the Arduino. We coded the entire project and uploaded it unto the chip. We then used an adapter to transfer the input from the Arduino to our phones and tested the output to ensure it worked.

## Challenges we ran into: Unfortunately there was a lack of hardware at our disposal. We wanted to implement bluetooth technology to send data to our phones without wires and even tweet weather alerts. However there was no bluetooth hardware components so we were unable to achieve this. Instead we just used an adapter to connect the arduino to our phone and show a test output. Testing was also an issue since we were not able to generate extreme cold and warm weathers so we had to change our code to test these parameters.

## Accomplishments that we're proud of: We had very little experience in using Grove Kits and were able to figure out a way to implement our project. Also we were able to change our original idea due to there being a limitation of bluetooth and WiFi shield components.

## What we learned: We learned how to use and code the sensors in a Grove Kit. We also improved our knowledge of Arduino and building circuits.

## What's next for Home Automation and Security: Future improvements and Modifications to improvements would be using bluetooth and WiFi to send twitter alerts to people on the user's contact list. In the future we may also include more components to the circuit for example installing a remote button that can contact the police in the case of there being an intruder. We may also install other types of sensors such as touch sensors that may be placed on a welcome mat or door handle during long periods away from home.

Code:

# include

# include "rgb\_lcd.h"

# include

rgb\_lcd lcd;

float temperature; //stores temperature
int lightValue; //stores light value
int soundValue; //stores sound value
bool errorTemp = false;
bool errorLight = false;
bool errorSound = false;
bool errorTempCold = false;
bool errorTempHot = false;
int lights = 0;
int cold = 0;
int hot = 0;
int intruder = 0;

const int B = 4275;

const int R0 = 100000;

const int pinTempSensor = A0;

const int pinLightSensor = A1;
const int pinSoundSensor = A2;
const int pinLEDRed = 9;
const int pinLEDGreen = 8;

void setup() {
 lcd.begin(16, 2);
 Serial.begin(9600);
}

void loop() {
 temperature = 0;
 temp(); //function that detects the temperature
 light(); //function that detects light
 sound(); //function that detects sounds
 lightMessages(); //function that checks conditions
 temperatureMessages(); //function that outputs everything to the user
 ok(); //function that ensures all parameters are correctly calculated and tested
 serialErrors(); //function that checks logic and sends data to output function
}

void light() {
 lightValue = analogRead(pinLightSensor);
}

void sound() {
 soundValue = analogRead(pinSoundSensor);
 //Serial.println(soundValue);
 if(soundValue > 500) {
 errorSound = true;
 } else {
 errorSound = false;
 }
}

void temp() {
 int a = analogRead(pinTempSensor);
 float R = 1023.0/((float)a)-1.0;
 R = R0\*R;
 temperature = 1.0/(log(R/R0)/B+1/298.15)-303.14; // convert to temperature via datasheet
 delay(100);
}

void blinkLED() {
 analogWrite(pinLEDRed, HIGH);
 delay(500);
 analogWrite(pinLEDRed, LOW);
 delay(500);
}

void greenLED() {
 analogWrite(pinLEDGreen, HIGH);
}

void screenRed() {
 lcd.setRGB(255,0,0);
}

void screenBlue() {
 lcd.setRGB(0,0,255);
}

void screenNormal() {
 lcd.setRGB(0,50,50);
}

void serialErrors() {
 if (errorSound == false) {
 if (errorLight == true) {
 cold = 0;
 hot = 0;
 intruder = 0;
 if(lights == 0) {

 Serial.println("Important: Lights are on at home!");
 lights++;
 } else {
 Serial.print("");
 }
 } else if (errorTempCold == true) {
 lights = 0;
 hot = 0;
 intruder = 0;
 if(cold == 0) {
 Serial.println("Important: The temperature at home is low!");
 cold++;
 } else {
 Serial.print("");
 }
 } else if (errorTempHot == true) {
 lights = 0;
 cold = 0;
 intruder = 0;
 if(hot == 0){
 Serial.println("Important: The temperature at home is high!");
 hot++;
 } else {
 Serial.print("");
 }
 }
 } else {
 lights = 0;
 cold = 0;
 hot = 0;
 if(intruder == 0) {
 Serial.println("IMPORTANT: There was a very loud sound at home! Possible intruder.");
 intruder++;
 } else {
 Serial.print("");
 }
 }
}

void ok() {
 if(errorSound == false) {
 if (errorTemp == false && errorLight == false) {
 lcd.clear();
 analogWrite(pinLEDGreen, HIGH);
 lcd.setCursor(0, 0);
 lcd.print("Everything is ok");
 lcd.setCursor(1,1);
 lcd.print("Temp = ");
 lcd.print(temperature);
 lcd.print("C");
 screenNormal();
 }
 }
}

void lightMessages() {
 if(lightValue > 500) {
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print("Lights are on!");
 screenRed();
 blinkLED();
 errorLight = true;
 } else {
 errorLight = false;
 }
}

void temperatureMessages() {
 if (errorSound == false) {
 if (temperature < 20) {
 lcd.clear();
 lcd.setCursor(0,1);
 lcd.print("Extreme Cold!");
 screenBlue();
 blinkLED();
 errorTemp = true;
 errorTempCold = true;
 errorTempHot = false;
 } else if (temperature > 30) {
 lcd.clear();

 lcd.setCursor(0,1);
 lcd.print("Extreme Heat!");
 screenRed();
 blinkLED();
 errorTemp = true;
 errorTempHot = true;
 errorTempCold = false;
 } else {
 errorTemp = false;
 errorTempHot = false;
 errorTempCold = false;
 }
 } else {
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("LOUD SOUND");
 lcd.setCursor(0,1);
 lcd.print("DETECTED!");
 screenRed();
 blinkLED();
 delay(5000);
 if (soundValue < 500) {
 errorSound = false;
 } else {
 errorSound = true;
 }
 }
}
## Inspiration

We as a team shared the same interest in knowing more about Machine Learning and its applications. upon looking at the challenges available, we were immediately drawn to the innovation factory and their challenges, and thought of potential projects revolving around that category. We started brainstorming, and went through over a dozen design ideas as to how to implement a solution related to smart cities. By looking at the different information received from the camera data, we landed on the idea of requiring the raw footage itself and using it to look for what we would call a distress signal, in case anyone felt unsafe in their current area.

## What it does

We have set up a signal that if done in front of the camera, a machine learning algorithm would be able to detect the signal and notify authorities that maybe they should check out this location, for the possibility of catching a potentially suspicious suspect or even being present to keep civilians safe.

## How we built it

First, we collected data off the innovation factory API, and inspected the code carefully to get to know what each part does. After putting pieces together, we were able to extract a video footage of the nearest camera to us. A member of our team ventured off in search of the camera itself to collect different kinds of poses to later be used in training our machine learning module. Eventually, due to compiling issues, we had to scrap the training algorithm we made and went for a similarly pre-trained algorithm to accomplish the basics of our project.

## Challenges we ran into

Using the Innovation Factory API, the fact that the cameras are located very far away, the machine learning algorithms unfortunately being an older version and would not compile with our code, and finally the frame rate on the playback of the footage when running the algorithm through it.

## Accomplishments that we are proud of

Ari: Being able to go above and beyond what I learned in school to create a cool project

Donya: Getting to know the basics of how machine learning works

Alok: How to deal with unexpected challenges and look at it as a positive change

Sudhanshu: The interesting scenario of posing in front of a camera while being directed by people recording me from a mile away.

## What I learned

Machine learning basics, Postman, working on different ways to maximize playback time on the footage, and many more major and/or minor things we were able to accomplish this hackathon all with either none or incomplete information.

## What's next for Smart City SOS

hopefully working with innovation factory to grow our project as well as inspiring individuals with similar passion or desire to create a change.