mirror of
https://github.com/bitlair/bitlair_doorduino.git
synced 2025-05-13 12:20:07 +02:00
added: toggle lock when an ibutton is authenticated
This commit is contained in:
parent
c4bd516a45
commit
5333da3e5c
1 changed files with 36 additions and 4 deletions
|
@ -7,9 +7,12 @@
|
||||||
#include "Entropy.h"
|
#include "Entropy.h"
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
|
|
||||||
#define PIN_1WIRE 2
|
#define PIN_OPEN 4
|
||||||
#define PIN_LEDGREEN 3
|
#define PIN_CLOSE 5
|
||||||
#define PIN_LEDRED 4
|
|
||||||
|
#define PIN_1WIRE 13
|
||||||
|
#define PIN_LEDGREEN 12
|
||||||
|
#define PIN_LEDRED 11
|
||||||
|
|
||||||
#define CMD_BUFSIZE 64
|
#define CMD_BUFSIZE 64
|
||||||
#define CMD_TIMEOUT 10000 //command timeout in milliseconds
|
#define CMD_TIMEOUT 10000 //command timeout in milliseconds
|
||||||
|
@ -82,6 +85,9 @@ void setup()
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("DEBUG: Board started");
|
Serial.println("DEBUG: Board started");
|
||||||
|
|
||||||
|
pinMode(PIN_OPEN, OUTPUT);
|
||||||
|
pinMode(PIN_CLOSE, OUTPUT);
|
||||||
|
|
||||||
pinMode(PIN_LEDGREEN, OUTPUT);
|
pinMode(PIN_LEDGREEN, OUTPUT);
|
||||||
pinMode(PIN_LEDRED, OUTPUT);
|
pinMode(PIN_LEDRED, OUTPUT);
|
||||||
|
|
||||||
|
@ -371,6 +377,32 @@ void ParseCMD(char* cmdbuf, uint8_t cmdbuffill)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToggleLock()
|
||||||
|
{
|
||||||
|
static bool lockopen;
|
||||||
|
|
||||||
|
if (lockopen)
|
||||||
|
{
|
||||||
|
Serial.println("closing lock");
|
||||||
|
digitalWrite(PIN_CLOSE, HIGH);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(PIN_CLOSE, LOW);
|
||||||
|
lockopen = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("opening lock");
|
||||||
|
digitalWrite(PIN_OPEN, HIGH);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(PIN_OPEN, LOW);
|
||||||
|
lockopen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(10000);
|
||||||
|
|
||||||
|
Serial.println("finished lock action");
|
||||||
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
uint8_t addr[ADDRSIZE];
|
uint8_t addr[ADDRSIZE];
|
||||||
|
@ -409,7 +441,7 @@ void loop()
|
||||||
{
|
{
|
||||||
SetLEDState(LEDState_Authorized);
|
SetLEDState(LEDState_Authorized);
|
||||||
Serial.print("iButton authenticated\n");
|
Serial.print("iButton authenticated\n");
|
||||||
delay(1000);
|
ToggleLock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue