relay
relay

--- a/LipoStorage/LipoStorage.ino
+++ b/LipoStorage/LipoStorage.ino
@@ -8,11 +8,12 @@
 
 #include <Wire.h>
 
+#define RELAY 4
 int debug = 1;
 
 int analogValue;
 float voltage;
-float minimumVoltage = 3.85;
+float minimumVoltage = 11.98;
 int timesUnderMinimumVoltage = 0;
 int maxUnderMinimumVoltage = 5;
 bool relayActivated = false;
@@ -25,6 +26,7 @@
   if ( debug >= 3 ) {
     Serial.println("Voltage: x.xx V");
   }
+  pinMode(RELAY, OUTPUT);
 }
 
 void loop() 
@@ -52,9 +54,9 @@
     }
     if ( timesUnderMinimumVoltage >= maxUnderMinimumVoltage ) {
       relayActivated = true;
+      digitalWrite(RELAY, HIGH);
       if ( debug >= 1 ) {
         Serial.println("Send signal to relay to disconnect battery");
-        // to do relay part
       }
     }    
   } else {
@@ -67,9 +69,9 @@
     }
     if ( timesUnderMinimumVoltage == 0 ) {
       relayActivated = false;
+      digitalWrite(RELAY, LOW);
       if ( debug >= 1 ) {
         Serial.println("Send signal to relay to reconnect battery");
-        // to do relay part        
       }      
     }
   }

comments