Dependents:   InjectorValveFourthMicro InjectorValveFourthMicro1 InjectorValveFourthMicro2 ReadingInLines_copy

Fork of PWM-Coil-driver by David Wahl

Revision:
6:e8395448fc8b
Parent:
4:ca7107dff643
Child:
7:91a84a44c81e
--- a/coil-driver.cpp	Tue Jun 20 19:51:40 2017 +0000
+++ b/coil-driver.cpp	Thu Jul 20 20:33:16 2017 +0000
@@ -36,11 +36,23 @@
 
 };
 
+char Coil::status()
+{
+    char status;
+    if(controlOut.read() == 0) {
+        status = 0;
+    } else {
+        status = 1;
+    }
+}
+
 void Coil::on()
 {
-    controlOut.write(1.0);
-    wait_us(spikeus);
-    controlOut.pulsewidth_us(holdpulse_us);
+    if(controlOut.read() == 0.0) {
+        controlOut.write(1.0);
+        wait_us(spikeus);
+        controlOut.pulsewidth_us(holdpulse_us);
+    }
 }
 
 void Coil::off()