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
Diff: setup.cpp
- Revision:
- 4:628468ce3e86
- Parent:
- 3:2f7a7e2cd49e
--- 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; -} - - - -