Safe of the God's was a group project. For the project we were given the task to create an electronic safe with an embedded system.

Dependencies:   mbed Servo PinDetect

Files at this revision

API Documentation at this revision

Comitter:
monwonga3
Date:
Sat Dec 29 07:04:53 2018 +0000
Parent:
3:2f7a7e2cd49e
Commit message:
Safe of the Gods

Changed in this revision

actuators.cpp Show diff for this revision Revisions of this file
actuators.h Show diff for this revision Revisions of this file
authentication.cpp Show diff for this revision Revisions of this file
authentication.h Show diff for this revision Revisions of this file
lock.cpp Show diff for this revision Revisions of this file
lock.h Show diff for this revision Revisions of this file
open.cpp Show diff for this revision Revisions of this file
open.h Show diff for this revision Revisions of this file
parameters.h Show diff for this revision Revisions of this file
powerManagement.cpp Show diff for this revision Revisions of this file
powerManagement.h Show diff for this revision Revisions of this file
setup.cpp Show diff for this revision Revisions of this file
setup.h Show diff for this revision Revisions of this file
src/actuators.cpp Show annotated file Show diff for this revision Revisions of this file
src/actuators.h Show annotated file Show diff for this revision Revisions of this file
src/authentication.cpp Show annotated file Show diff for this revision Revisions of this file
src/authentication.h Show annotated file Show diff for this revision Revisions of this file
src/lock.cpp Show annotated file Show diff for this revision Revisions of this file
src/lock.h Show annotated file Show diff for this revision Revisions of this file
src/open.cpp Show annotated file Show diff for this revision Revisions of this file
src/open.h Show annotated file Show diff for this revision Revisions of this file
src/parameters.h Show annotated file Show diff for this revision Revisions of this file
src/setup.cpp Show annotated file Show diff for this revision Revisions of this file
src/setup.h Show annotated file Show diff for this revision Revisions of this file
--- a/actuators.cpp	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the actuators of the safe
-* Language:  NBC
-*/
-#include "actuators.h"
-#include "parameters.h"
-#include "Servo.h"
-
-
-Servo rcServo1(p21); // pwm
-Servo rcServo2(p22); // pwm
-Servo middle(p23);
-
-/*
-* Function:  turnsRcServosRight
-* --------------------
-*  Turns the servos to the right
-*
-*
-*/
-void turnsRcServosRight() {
-	printf("I entered turnsRCServoRight");
-	rcServo1 = 1.0f;
-	rcServo2 = 1.0f;
-}
-
-/*
-* Function:  urnsRcServosLeft
-* --------------------
-*  Turns the servos to the right
-*
-*
-*/
-void turnsRcServosLeft() {
-	rcServo1 = 0.0f;
-	rcServo2 = 0.0f;
-}
-
-
-/*
-* Function:  openSafe
-* --------------------
-*  Opens the safe
-*/
-void openSafe() {
-	middle = 1.0f;
-	wait(1);
-	turnsRcServosRight();
-}
-
-/*
-* Function:  lockSafe
-* --------------------
-*  Locks the safe
-*/
-void lockSafe() {
-	turnsRcServosLeft();
-	wait(3);
-	middle = 1.0f;
-}
-
-
--- a/actuators.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the actuators of the safe
-* Language:  NBC
-*/
-
-/*
-* Function:  turnsRcServosRight
-* --------------------
-*  Turns the servos to the right
-*
-*
-*/
-void turnsRcServosRight() ;
-
-/*
-* Function:  urnsRcServosLeft
-* --------------------
-*  Turns the servos to the right
-*
-*
-*/
-void turnsRcServosLeft() ;
-
-
-/*
-* Function:  openSafe
-* --------------------
-*  Opens the safe
-*/
-void openSafe() ;
-
-/*
-* Function:  lockSafe
-* --------------------
-*  Locks the safe
-*/
-void lockSafe() ;
-
-
-
-
--- a/authentication.cpp	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls Input and Output Data
-* Language: C
-*/
-#include "authentication.h"
-#include "powerManagement.h"
-#include "parameters.h"
-
-int p1;
-int p2;
-int p3;
-int p4;
-
-int entryNum1;
-int entryNum2;
-int entryNum3;
-int entryNum4;
-
-
-AnalogIn pot1(p15);
-AnalogIn pot2(p16);
-AnalogIn pot3(p18);
-AnalogIn pot4(p19);
-
-bool bluetoothCode = false;
-bool bluetoothSetup = false;
-Serial blue(p28,p27);
-Serial pc(USBTX, USBRX);
-
-/*
-* Function: setEntrySequence
-* --------------------
-*  Reads in user's entry sequence attempt
-*/
-void setEntrySequenceAttempt() {
-	entryNum1 = float(pot1) * 6;
-	entryNum2 = float(pot2) * 6;
-	entryNum3 = float(pot3) * 6;
-	entryNum4 = float(pot4) * 6;
-}
-
-/*
-* Function:  CorrectEntrySequenceAttempt
-* --------------------
-*  Checks whether the user's entry sequence attempt is correct
-*
-*  returns: true if the entry sequence attempt from the user matches
-*  the set entry sequence otherwise false
-*
-*/
-bool CorrectEntrySequenceAttempt() {
-	if (bluetoothCode) {
-		return true;
-
-	}
-	p1 = float(pot1) * 6;
-	p2 = float(pot2) * 6;
-	p3 = float(pot3) * 6;
-	p4 = float(pot4) * 6;
-
-	return (checkPot(p1,entryNum1) && checkPot(p2,entryNum2) && checkPot(p3,entryNum3) && checkPot(p3,entryNum3));
-}
-
-void printPotValues() {
-	pc.printf("pot1 is %f", pot1);
-	
-}
-
-bool checkPot(int p1, int p2) {
-	return (p2 - p1) < 2 && (p1 - p2) > -2;
-
-}
-
-bool checkBluetooth() {
-	if (bluetoothSetup) {
-		bluetoothSetup = false;
-		return true;
-	}
-	return false;
-}
-
-
-
-/*
-* Function:  parse_bluetooth
-* --------------------
-*  bluetooth stuff EDIT LATER
-*
-*  returns:
-*
-*/
-void parse_bluetooth()
-{
-    switch (blue.getc()) {
-        case 'o':
-            bluetoothCode  = true;
-            break;
-        case 'l':
-            bluetoothCode = false;
-            break;
-        case 's':
-			bluetoothSetup = true;
-			break;
-    }
-    
-}
-
-void start_bluetooth() {
-	 blue.attach(&parse_bluetooth, Serial::RxIrq);	
-}
-
-/*
-* Function:  sdCard
-* --------------------
-*  sdCard stuff EDIT LATER
-*
-*  returns:
-*
-*/
-void sdCard() {
-
-}
-
-
--- a/authentication.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls Input and Output Data
-* Language: C
-*/
-/*
-* Function: setEntrySequence
-* --------------------
-*  Reads in user's entry sequence attempt
-*/
-void setEntrySequenceAttempt();
-/*
-* Function:  CorrectEntrySequenceAttempt
-* --------------------
-*  Checks whether the user's entry sequence attempt is correct
-*
-*  returns: true if the entry sequence attempt from the user matches
-*  the set entry sequence otherwise false
-*
-*/
-bool CorrectEntrySequenceAttempt();
-
-bool checkPot(int p1, int p2);
-
-bool checkBluetooth();
-
-void printPotValues();
-
-/*
-* Function:  bluetooth
-* --------------------
-*  bluetooth stuff EDIT LATER
-*
-*  returns:
-*
-*/
-void parse_bluetooth();
-
-void start_bluetooth();
-
-/*
-* Function:  sdCard
-* --------------------
-*  sdCard stuff EDIT LATER
-*
-*  returns:
-*
-*/
-void sdCard();
-
-
--- a/lock.cpp	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the LOCK state of the machine
-* Language: C
-*/
-#include "lock.h"
-#include "authentication.h"
-#include "actuators.h"
-#include "powerManagement.h"
-#include "parameters.h"
-
-/*
-* Function:  lock
-* --------------------
-*  Locks safe
-*
-*  returns: the next state in the state machine
-*  Open: After it has been locked
-*
-*/
-enum states lock() {
-	if(authenticateLock()) {
-		openSafe();
-		wait(5);
-		return OPEN;
-	} else {
-		return LOCK;
-	}
-}
-
-/*
-* Function: authenticate
-* ----------------------------
-*  Checks whether a cup was found through the sonar sensor
-*
-*  returns: true if cup found else false
-*/
-bool authenticateLock() {
-    return CorrectEntrySequenceAttempt();
-}
-
--- a/lock.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the LOCK state of the machine
-* Language: C
-*/
-
-/*
-* Function:  lock
-* --------------------
-*  Locks safe
-*
-*  returns: the next state in the state machine
-*  Open: After it has been locked
-*
-*/
-enum states lock();
-
-/*
-* Function: authenticate
-* ----------------------------
-*  Checks whether a cup was found through the sonar sensor
-*
-*  returns: true if cup found else false
-*/
-bool authenticateLock();
-
--- a/open.cpp	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the OPEN state of the machine
-* Language:  C
-*/
-#include "open.h"
-#include "authentication.h"
-#include "actuators.h"
-#include "parameters.h"
-
-/*
-* Function:  OPEN
-* --------------------
-*  Calls the functions needed to for the open state
-*
-*
-*  returns: the next state in the state machine
-*  LOCK: if closed properly
-*  ALARM: if cup is not found after searching in a full circle
-*
-*/
-enum states open() {
-    if (authenticateOpen()) {
-        return OPEN;
-    } else {
-        lockSafe();
-        wait(5);
-        return LOCK;
-    }
-}
-
-/*
-* Function: authenticate
-* ----------------------------
-*  Checks whether a cup was found through the sonar sensor
-*
-*  returns: true if cup found else false
-*/
-bool authenticateOpen() {
-    return CorrectEntrySequenceAttempt();
-}
-
-
--- a/open.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the OPEN state of the machine
-* Language:  C
-*/
-/*
-* Function:  OPEN
-* --------------------
-*  Calls the functions needed to for the open state
-*
-*
-*  returns: the next state in the state machine
-*  LOCK: if closed properly
-*  ALARM: if cup is not found after searching in a full circle
-*
-*/
-enum states open();
-
-/*
-* Function: authenticate
-* ----------------------------
-*  Checks whether a cup was found through the sonar sensor
-*
-*  returns: true if cup found else false
-*/
-bool authenticateOpen();
-
-
--- a/parameters.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-#include "mbed.h"
-/*
- * Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga 
- * Purpose: Controls the parameters of the safe
- * Language:  C
- */
-enum states{OPEN, LOCK, SETUP};/*Name of the states in the Safe Cups State Machine*/
-#define  maxFailedAtttemps 6; /*number of max failed attemps entered before alarm is thrown*/
-
-
-
--- a/powerManagement.cpp	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls Input and Output Data
-* Language: C
-*/
-#include "powerManagement.h"
-#include "parameters.h"
-
-int batteryLevels;
-
-/*
-* Function: powerSavingMode
-* --------------------
-*  Controls what is on while the safe is on this mode
-*/
-void powerSavingMode() {
-//however we decide to implement 
-}
-
-/*
-* Function: getBatteryLevels
-* --------------------
-*  Get the battery level for the safe
-*
-*  returns: the battery level for the safe
-*
-*/
-int getBatteryLevels() {
-	//EDIT LATER maybe have it send a notification in the future
-	return batteryLevels;
-}
-
--- a/powerManagement.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls Input and Output Data
-* Language: C
-*/
-
-/*
-* Function: powerSavingMode
-* --------------------
-*  Controls what is on while the safe is on this mode
-*/
-void powerSavingMode();
-
-/*
-* Function: getBatteryLevels
-* --------------------
-*  Get the battery level for the safe
-*
-*  returns: the battery level for the safe
-*
-*/
-int getBatteryLevels();
-
--- a/setup.cpp	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the SETUP state of the machine
-* Language: C
-*/
-#include "setup.h"
-#include "authentication.h"
-#include "parameters.h"
-#include "actuators.h"
-#include "PinDetect.h"
-
-
-PinDetect button(p8);
-
-volatile bool buttonHit = false;
-bool firstTime = true;
-void button_hit_callback (void)
-{
-    buttonHit = !buttonHit;
-}
-/*
-* Function:  setup
-* --------------------
-*  Calls the functions needed to setup the entry sequence for the safe.
-*
-*  returns: the next state in the state machine
-*  LOCK: after entry sequence has been entered
-*
-*/
-
-
-enum states setup()
-{
-    printf("%d",buttonHit);
-    if (firstTime) {
-        button.mode(PullUp);
-        button.attach_deasserted(&button_hit_callback);
-        button.setSampleFrequency();
-        firstTime = false;
-    }
-    if(buttonHit || checkBluetooth()) {
-        setEntrySequenceAttempt();
-        wait(5);
-        lockSafe();
-        wait(5);
-        return LOCK;
-    }
-    return SETUP;
-}
-
-
-
-
--- a/setup.h	Tue Nov 13 03:19:06 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the SETUP state of the machine
-* Language: C
-*/
-
-/*
-* Function:  setup
-* --------------------
-*  Calls the functions needed to setup the entry sequence for the safe.
-*
-*  returns: the next state in the state machine
-*  LOCK: after entry sequence has been entered
-*
-*/
-
-
-enum states setup();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/actuators.cpp	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,63 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the actuators of the safe
+* Language:  C++
+*/
+#include "actuators.h"
+#include "parameters.h"
+#include "Servo.h"
+
+
+Servo rcServo1(p21); // pwm
+Servo rcServo2(p22); // pwm
+Servo middle(p23);
+
+/*
+* Function:  turnsRcServosRight
+* --------------------
+*  Turns the servos to the right
+*
+*
+*/
+void turnsRcServosRight() {
+	printf("I entered turnsRCServoRight");
+	rcServo1 = 1.0f;
+	rcServo2 = 1.0f;
+}
+
+/*
+* Function:  turnsRcServosLeft
+* --------------------
+*  Turns the servos to the right
+*
+*
+*/
+void turnsRcServosLeft() {
+	rcServo1 = 0.0f;
+	rcServo2 = 0.0f;
+}
+
+
+/*
+* Function:  openSafe
+* --------------------
+*  Opens the safe
+*/
+void openSafe() {
+	middle = 1.0f;
+	wait(1);
+	turnsRcServosRight();
+}
+
+/*
+* Function:  lockSafe
+* --------------------
+*  Locks the safe
+*/
+void lockSafe() {
+	turnsRcServosLeft();
+	wait(3);
+	middle = 1.0f;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/actuators.h	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,42 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the actuators of the safe
+* Language:  C++
+*/
+
+/*
+* Function:  turnsRcServosRight
+* --------------------
+*  Turns the servos to the right
+*
+*
+*/
+void turnsRcServosRight() ;
+
+/*
+* Function:  turnsRcServosLeft
+* --------------------
+*  Turns the servos to the right
+*
+*
+*/
+void turnsRcServosLeft() ;
+
+
+/*
+* Function:  openSafe
+* --------------------
+*  Opens the safe
+*/
+void openSafe() ;
+
+/*
+* Function:  lockSafe
+* --------------------
+*  Locks the safe
+*/
+void lockSafe() ;
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/authentication.cpp	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,114 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls Input and Output Data
+* Language: C++
+*/
+#include "authentication.h"
+#include "parameters.h"
+
+int p1;
+int p2;
+int p3;
+int p4;
+
+int entryNum1;
+int entryNum2;
+int entryNum3;
+int entryNum4;
+
+
+AnalogIn pot1(p15);
+AnalogIn pot2(p16);
+AnalogIn pot3(p18);
+AnalogIn pot4(p19);
+
+bool bluetoothCode = false;
+bool bluetoothSetup = false;
+Serial blue(p28,p27);
+Serial pc(USBTX, USBRX);
+
+/*
+* Function: setEntrySequence
+* --------------------
+*  Reads in user's entry sequence attempt
+*/
+void setEntrySequenceAttempt() {
+	entryNum1 = float(pot1) * 6;
+	entryNum2 = float(pot2) * 6;
+	entryNum3 = float(pot3) * 6;
+	entryNum4 = float(pot4) * 6;
+}
+
+/*
+* Function:  CorrectEntrySequenceAttempt
+* --------------------
+*  Checks whether the user's entry sequence attempt is correct
+*
+*  returns: true if the entry sequence attempt from the user matches
+*  the set entry sequence otherwise false
+*
+*/
+bool CorrectEntrySequenceAttempt() {
+	if (bluetoothCode) {
+		return true;
+
+	}
+	p1 = float(pot1) * 6;
+	p2 = float(pot2) * 6;
+	p3 = float(pot3) * 6;
+	p4 = float(pot4) * 6;
+
+	return (checkPot(p1,entryNum1) && checkPot(p2,entryNum2) && checkPot(p3,entryNum3) && checkPot(p3,entryNum3));
+}
+
+void printPotValues() {
+	pc.printf("pot1 is %f", pot1);
+	
+}
+
+bool checkPot(int p1, int p2) {
+	return (p2 - p1) < 2 && (p1 - p2) > -2;
+
+}
+
+bool checkBluetooth() {
+	if (bluetoothSetup) {
+		bluetoothSetup = false;
+		return true;
+	}
+	return false;
+}
+
+
+
+/*
+* Function:  parse_bluetooth
+* --------------------
+*  bluetooth stuff EDIT LATER
+*
+*  returns:
+*
+*/
+void parse_bluetooth()
+{
+    switch (blue.getc()) {
+        case 'o':
+            bluetoothCode  = true;
+            break;
+        case 'l':
+            bluetoothCode = false;
+            break;
+        case 's':
+			bluetoothSetup = true;
+			break;
+    }
+    
+}
+
+void start_bluetooth() {
+	 blue.attach(&parse_bluetooth, Serial::RxIrq);	
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/authentication.h	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,43 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls Input and Output Data
+* Language: C++
+*/
+/*
+* Function: setEntrySequence
+* --------------------
+*  Reads in user's entry sequence attempt
+*/
+void setEntrySequenceAttempt();
+/*
+* Function:  CorrectEntrySequenceAttempt
+* --------------------
+*  Checks whether the user's entry sequence attempt is correct
+*
+*  returns: true if the entry sequence attempt from the user matches
+*  the set entry sequence otherwise false
+*
+*/
+bool CorrectEntrySequenceAttempt();
+
+bool checkPot(int p1, int p2);
+
+bool checkBluetooth();
+
+void printPotValues();
+
+/*
+* Function:  bluetooth
+* --------------------
+*  bluetooth stuff EDIT LATER
+*
+*  returns:
+*
+*/
+void parse_bluetooth();
+
+void start_bluetooth();
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lock.cpp	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,40 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the LOCK state of the machine
+* Language: C++
+*/
+#include "lock.h"
+#include "authentication.h"
+#include "actuators.h"
+#include "parameters.h"
+
+/*
+* Function:  lock
+* --------------------
+*  Locks safe
+*
+*  returns: the next state in the state machine
+*  Open: After it has been locked
+*
+*/
+enum states lock() {
+	if(authenticateLock()) {
+		openSafe();
+		wait(5);
+		return OPEN;
+	} else {
+		return LOCK;
+	}
+}
+
+/*
+* Function: authenticateLock
+* ----------------------------
+*  Checks whether a cup was found through the sonar sensor
+*
+*  returns: true if cup found else false
+*/
+bool authenticateLock() {
+    return CorrectEntrySequenceAttempt();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lock.h	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,26 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the LOCK state of the machine
+* Language: C++
+*/
+
+/*
+* Function:  lock
+* --------------------
+*  Locks safe
+*
+*  returns: the next state in the state machine
+*  Open: After it has been locked
+*
+*/
+enum states lock();
+
+/*
+* Function: authenticateLock
+* ----------------------------
+*  Checks whether a cup was found through the sonar sensor
+*
+*  returns: true if cup found else false
+*/
+bool authenticateLock();
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/open.cpp	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,43 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the OPEN state of the machine
+* Language:  C++
+*/
+#include "open.h"
+#include "authentication.h"
+#include "actuators.h"
+#include "parameters.h"
+
+/*
+* Function:  open
+* --------------------
+*  Calls the functions needed to for the open state
+*
+*
+*  returns: the next state in the state machine
+*  LOCK: if closed properly
+*  ALARM: if cup is not found after searching in a full circle
+*
+*/
+enum states open() {
+    if (authenticateOpen()) {
+        return OPEN;
+    } else {
+        lockSafe();
+        wait(5);
+        return LOCK;
+    }
+}
+
+/*
+* Function: authenticate
+* ----------------------------
+*  Checks whether a cup was found through the sonar sensor
+*
+*  returns: true if cup found else false
+*/
+bool authenticateOpen() {
+    return CorrectEntrySequenceAttempt();
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/open.h	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,28 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the OPEN state of the machine
+* Language:  C++
+*/
+/*
+* Function:  open
+* --------------------
+*  Calls the functions needed to for the open state
+*
+*
+*  returns: the next state in the state machine
+*  LOCK: if closed properly
+*  ALARM: if cup is not found after searching in a full circle
+*
+*/
+enum states open();
+
+/*
+* Function: authenticate
+* ----------------------------
+*  Checks whether a cup was found through the sonar sensor
+*
+*  returns: true if cup found else false
+*/
+bool authenticateOpen();
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parameters.h	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,10 @@
+#include "mbed.h"
+/*
+ * Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga 
+ * Purpose: Controls the parameters of the safe
+ * Language:  C++
+ */
+enum states{OPEN, LOCK, SETUP};/*Name of the states in the Safe Cups State Machine*/
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/setup.cpp	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,60 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the SETUP state of the machine
+* Language: C++
+*/
+#include "setup.h"
+#include "authentication.h"
+#include "parameters.h"
+#include "actuators.h"
+#include "PinDetect.h"
+
+
+PinDetect button(p8);
+
+volatile bool buttonHit = false;
+bool firstTime = true;
+
+/*
+* Function:  button_hit_callback
+* --------------------
+*  Changes boolean buttonHit inversly when called
+*
+*/
+void button_hit_callback (void)
+{
+    buttonHit = !buttonHit;
+}
+/*
+* Function:  setup
+* --------------------
+*  Calls the functions needed to setup the entry sequence for the safe.
+*
+*  returns: the next state in the state machine
+*  LOCK: after entry sequence has been entered
+*
+*/
+
+
+enum states setup()
+{
+    printf("%d",buttonHit);
+    if (firstTime) {
+        button.mode(PullUp);
+        button.attach_deasserted(&button_hit_callback);
+        button.setSampleFrequency();
+        firstTime = false;
+    }
+    if(buttonHit || checkBluetooth()) {
+        setEntrySequenceAttempt();
+        wait(5);
+        lockSafe();
+        wait(5);
+        return LOCK;
+    }
+    return SETUP;
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/setup.h	Sat Dec 29 07:04:53 2018 +0000
@@ -0,0 +1,18 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the SETUP state of the machine
+* Language: C
+*/
+
+/*
+* Function:  setup
+* --------------------
+*  Calls the functions needed to setup the entry sequence for the safe.
+*
+*  returns: the next state in the state machine
+*  LOCK: after entry sequence has been entered
+*
+*/
+
+
+enum states setup();