Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

OpenAccess Exit button/relay

OpenAccess Exit button/relay

This has to do with the exit button/relay.  I call these functions from elsewhere, but basically it sets the timeout for activating the exit relay.  I also use this as a timeout to enter commands to the system (enter or leave modes, like adding users)

//exit button stuff
const int exit_button = 48; //digital pin the exit button is attached to
const int exit_relay = 0; //relay the door solenoid is on
const unsigned long exit_time = 3000; //time to keep the door open in thousandths of a second
boolean exiting = 0; //whether or not the door should be open (and timer running)
unsigned long exit_start_time = 0; //used for count down timer

That is the initialization; sets the button, relay, timeout, and two variables so it can let the rest of the code execute while it’s open.

void exit()
{
logging(logDate());
logging(” – “);
loggingln(“exit relay open”);
exiting = 1;
exit_start_time = current_time;
digitalWrite(relaysToPins[exit_relay], HIGH);
}

That starts the ‘exiting’ procedure, starts the timer rolling and opens the door.

void exit_timeout()
{
logging(logDate());
logging(” – “);
loggingln(“exit relay closed”);
LCD_default();
RFID_reset();
exiting = 0; //no longer in exiting mode
//exit_start_time = 0; //not needed
digitalWrite(relaysToPins[exit_relay], LOW); //close door
}

That stops the exit procedure, pretty simple really.

if (!digitalRead(exit_button)) //exit button pressed
{
//Serial.println(“exiting”);
exit();
}
//Serial.println(“past exiting”);

That checks to see if the exit button was pressed, and starts the exit procedure.

if (exiting)
{
if (current_time – exit_start_time > exit_time) //exit time out loop
{
exit_timeout();
}
}

That checks to see if the door should be re-locked (you can of course extend the timer with more code that backs up the start time to cheat this check)

That’s all there is to the exit button and exit relay code.  It can also be called like any other relay from the I/O section, but it operates on its own unlike the others.  This is part of the OpenAccess project.

Read more Here

Pinned onto

Related Pins

Tutorial: DHT22 sensor with a PICmicro
Tutorial: DHT22 sensor with a PICmicro
BQ24650 Based MPPT li-ion Battery Chage Controller With Software MPPT adjust and 3 Channel LED P ...
BQ24650 Based MPPT li-ion Battery Chage Controller With Software MPPT adjust and 3 Channel LED PWM dimming.
Play beautiful music on an Arduino thumb piano
Play beautiful music on an Arduino thumb piano
40 dB attenuator
40 dB attenuator
A multimeter heads-up display with Arduino glasses
A multimeter heads-up display with Arduino glasses
Robotic fish swims under Arduino control
Robotic fish swims under Arduino control
Arduino Xylophone
Arduino Xylophone
MPPT Solar Charger Testing
MPPT Solar Charger Testing
Design and Application Guide of Bootstrap Circuit for High-Voltage Gate-Drive IC
Design and Application Guide of Bootstrap Circuit for High-Voltage Gate-Drive IC
ESLOV is the amazing new IoT invention kit from Arduino
ESLOV is the amazing new IoT invention kit from Arduino
μPC1237 based 2 channel speaker protector
μPC1237 based 2 channel speaker protector
ESP8266 WeatherStation Color
ESP8266 WeatherStation Color
Keyless piano project using Arduino uno
Keyless piano project using Arduino uno
IoT Wardrobe
IoT Wardrobe
Automotive CAN Transceivers
Automotive CAN Transceivers
Restoring a vintage Xerox Alto day 8: it boots!
Restoring a vintage Xerox Alto day 8: it boots!
Sonicare toothbrush teardown: microcontroller, H bridge, and inductive charging
Sonicare toothbrush teardown: microcontroller, H bridge, and inductive charging
Reverse engineering a server CPU voltage regulator module
Reverse engineering a server CPU voltage regulator module
Building a sweet plastic MIDI controller
Building a sweet plastic MIDI controller
A DIY interactive book that uses digital gestures
A DIY interactive book that uses digital gestures

Top


Shares