diff --git a/ExtSens/src/main.cpp b/ExtSens/src/main.cpp index d445731..e771935 100644 --- a/ExtSens/src/main.cpp +++ b/ExtSens/src/main.cpp @@ -24,7 +24,7 @@ void setup() { analogReference(INTERNAL); sensorValue = analogRead(BATTERY_SENSE_PIN); v = sensorValue * 0.004659498; - batteryPcnt = (v * 100) / 4.2; + batteryPcnt = (v-3.0 * 100) / 1.2; while (myAHT10.begin() != true) { Serial.println(F("AHT10 not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free @@ -53,7 +53,7 @@ void loop() { send(msgMillis.set(cRun)); sensorValue = analogRead(BATTERY_SENSE_PIN); v = sensorValue * 0.004659498; - batteryPcnt = (v-3 * 100) / 1.2; + batteryPcnt = (v-3.0 * 100) / 1.2; sendBatteryLevel(batteryPcnt); send(msgVolts.set(v, 2)); //} diff --git a/MainDoorMyS/src/main.cpp b/MainDoorMyS/src/main.cpp index 781dc73..1c72553 100644 --- a/MainDoorMyS/src/main.cpp +++ b/MainDoorMyS/src/main.cpp @@ -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()){