solenoid valve

Dependents:   2019NHK_A_manual_red 2019NHK_A_manual_red 2019NHK_A_manual_blue

Files at this revision

API Documentation at this revision

Comitter:
ec30109b
Date:
Mon Sep 23 12:20:49 2019 +0000
Commit message:
new

Changed in this revision

air.cpp Show annotated file Show diff for this revision Revisions of this file
air.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c11087e1926d air.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/air.cpp	Mon Sep 23 12:20:49 2019 +0000
@@ -0,0 +1,38 @@
+#include "air.h"
+
+air::air():
+port_a(solenoid_2),
+port_b(solenoid_3),
+port_c(solenoid_4),
+port_d(solenoid_5)
+{
+    port_a.write(true);
+    port_b.write(false);
+    port_c.write(false);
+    port_d.write(true);
+}
+
+void air::solenoid1_close()
+{
+    port_a.write(true);
+    port_b.write(false);
+}
+
+void air::solenoid1_open()
+{
+    port_a.write(false);
+    port_b.write(true);
+}
+
+void air::solenoid2_close()
+{
+    port_c.write(false);
+    port_d.write(true);
+}
+
+void air::solenoid2_open()
+{
+    port_c.write(true);
+    port_d.write(false);
+}
+    
\ No newline at end of file
diff -r 000000000000 -r c11087e1926d air.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/air.h	Mon Sep 23 12:20:49 2019 +0000
@@ -0,0 +1,22 @@
+#ifndef AIR_H
+#define AIR_H
+
+#include "mbed.h"
+#include "pinconfig_main.h"
+
+class air
+{
+public:
+    air();
+    void solenoid1_close();
+    void solenoid1_open();
+    void solenoid2_close();
+    void solenoid2_open();
+    
+private:
+    DigitalOut port_a;
+    DigitalOut port_b;
+    DigitalOut port_c;
+    DigitalOut port_d;
+};
+#endif
\ No newline at end of file