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

Revision:
4:628468ce3e86
Parent:
2:04bbd14722bd
--- /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;
+}
+
+
+
+