Dependencies:   Motor mbed

Files at this revision

API Documentation at this revision

Comitter:
danielgoodies
Date:
Sun Jun 11 19:20:35 2017 +0000
Commit message:
LImit

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r fd1d9eb5ab5f Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Sun Jun 11 19:20:35 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/Motor/#c75b234558af
diff -r 000000000000 -r fd1d9eb5ab5f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jun 11 19:20:35 2017 +0000
@@ -0,0 +1,64 @@
+#include "Motor.h"
+#include "mbed.h"
+
+DigitalIn limitAtasLifter(PB_3, PullUp);  // Vertikal Atas: Lifter
+DigitalIn limitAtasSaucer(PB_2, PullUp);  // Vertikal Atas: Saucer
+DigitalIn limitBawah(PB_10, PullUp); // Vertikal Bawah
+DigitalIn limitKiri(PA_5, PullUp);  // Horizontal Kiri
+DigitalIn limitTengah(PC_9, PullUp);// Horizontal Tengah
+DigitalIn limitKanan(PC_8, PullUp); // Horizontal Kanan (Frisbee keluar)
+
+Motor powerScrew(PA_8, PC_1, PC_2); // pwm, fwd, rev
+Motor pulley(PA_10, PC_3, PC_0); 
+
+int state = 0;
+int up = 0;
+
+int main()
+{
+    float pwmPower  = -1.0;
+    while(1) {
+            /* limit switch atas */
+            if ((!limitAtasLifter) && (up)){
+                if(state == 0){
+                    state = 1;
+                }
+                up = 0;
+                pwmPower = -1.0;
+            }
+            
+            /* limit switch bawah */
+            if (!limitBawah){
+                if(state == 0){
+                    state = 1;
+                }
+                else if ((state == 1)||(up == 0)){
+                    state = 0;
+                }
+                
+                up = 1;
+                pwmPower = 1.0;
+            }
+            
+            /* limit switch saucer */
+            if ((!limitAtasSaucer) && (up)){
+                state = 0;
+                pwmPower = 1.0;
+            }
+            /*
+            else if ((limitAtasSaucer) && (up))
+            {
+                state = 1;
+                pwmPower = 1.0;
+            }
+            */
+            
+            /* motor */
+            if (state == 1){
+                powerScrew.speed(pwmPower);
+            }
+            else if (state == 0){
+                powerScrew.brake(1);
+            }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r fd1d9eb5ab5f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jun 11 19:20:35 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file