kh

Dependencies:   mbed PinDetect Servo

Revision:
0:28e05e1a3d1e
Child:
1:2c365f6da61d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lock.cpp	Sat Nov 10 19:30:54 2018 +0000
@@ -0,0 +1,39 @@
+/*
+* 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 "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(authenticate()) {
+		openSafe();
+		wait(5000);
+		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 authenticate() {
+    return CorrectEntrySequenceAttempt();
+}