This commit is contained in:
lexa
2020-11-19 20:53:01 +03:00
parent 279e09334f
commit f198dc1b95
2 changed files with 29 additions and 20 deletions

View File

@@ -18,8 +18,8 @@
#define TOP_LOCK A0
#define INT_LOCK A1
#define DOWN_LOCK A2
#define SMALL_LOCK A3
#define DOWN_LOCK A3
#define SMALL_LOCK A2
#define DOOR A4
#define TOP_LOCK_ID 0
@@ -58,47 +58,56 @@ void presentation()
present(SMALL_LOCK_ID, S_LOCK, "Small");
present(DOOR_ID, S_LOCK, "Door");
present(CUSTOM_ID, S_CUSTOM);
sendData(msgDoor, digitalRead(DOOR));
wait(100);
sendData(msgTop, digitalRead(TOP_LOCK));
wait(100);
sendData(msgInt, digitalRead(INT_LOCK));
wait(100);
sendData(msgDown, digitalRead(DOWN_LOCK));
wait(100);
sendData(msgSmall, digitalRead(SMALL_LOCK));
}
void setup() {
// put your setup code here, to run once:
bpDoor = !digitalRead(DOOR);
bpTop = !digitalRead(TOP_LOCK);
bpInt = !digitalRead(INT_LOCK);
bpSmall = !digitalRead(SMALL_LOCK);
bpDown = !digitalRead(DOWN_LOCK);
sendData(msgDoor, bpDoor);
wait(100);
sendData(msgTop, bpTop);
wait(100);
sendData(msgInt, bpInt);
wait(100);
sendData(msgDown, bpDown);
wait(100);
sendData(msgSmall, bpSmall);
}
void loop() {
static uint32_t cRun = millis();
bool bTop, bInt, bDown, bSmall, bDoor;
bTop = digitalRead(TOP_LOCK);
bInt = digitalRead(INT_LOCK);
bDown = digitalRead(DOWN_LOCK);
bSmall = digitalRead(SMALL_LOCK);
bDoor = digitalRead(DOOR);
bTop = !digitalRead(TOP_LOCK);
bInt = !digitalRead(INT_LOCK);
bDown = !digitalRead(DOWN_LOCK);
bSmall = !digitalRead(SMALL_LOCK);
bDoor = !digitalRead(DOOR);
if(bTop != bpTop){
bpTop = bTop;
sendData(msgTop, bDoor);
Serial.print(F("Top Lock-"));Serial.println(bTop);
sendData(msgTop, bTop);
}
if(bInt != bpInt){
bpInt = bInt;
Serial.print(F("Int Lock-"));Serial.println(bInt);
sendData(msgInt, bInt);
}
if(bDown != bpDown){
bpDown = bDown;
Serial.print(F("Down Lock-"));Serial.println(bDown);
sendData(msgDown, bDown);
}
if(bSmall != bpSmall){
bpSmall = bSmall;
Serial.print(F("Small Lock-"));Serial.println(bSmall);
sendData(msgSmall, bSmall);
}
if(bDoor != bpDoor){
bpDoor = bDoor;
Serial.print(F("Door-"));Serial.println(bDoor);
sendData(msgDoor, bDoor);
}
if((cRun + 29999) < millis()){