Untuk Kontrol Atas

Dependencies:   Motor mRotaryEncoder mbed

Files at this revision

API Documentation at this revision

Comitter:
danielgoodies
Date:
Mon Sep 19 15:38:00 2016 +0000
Commit message:
Kontrol Atas Muncrat

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
mRotaryEncoder.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Mon Sep 19 15:38:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/Motor/#c75b234558af
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mRotaryEncoder.lib	Mon Sep 19 15:38:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/charly/code/mRotaryEncoder/#2502b829d452
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 19 15:38:00 2016 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+#include "Motor.h"
+
+/* Pin Declaration */
+Motor Motor1(D6,D7,D8);
+DigitalIn encoderpin1(D4); /*Encoder punya 2 buah pin input, 1 Vcc, 1 Ground */
+DigitalIn encoderpin2(D5);
+
+
+/* Variable Declaration */
+int encoder0Pos = 0;
+int encoder0PinALast = 0;
+int n = 0;
+int i = 0;
+int boolean = 0;
+ 
+ /* Main Program */
+int main() {
+    Serial pc(USBTX,USBRX);
+    pc.baud(9600);
+
+    pc.printf(" Test Serial Monitor");
+    while (1) {
+            /*if(i>=0 && i<=100 && boolean == 0) {
+            i++; 
+                if(i==100) {
+                    boolean = 1;
+                }
+            }
+            
+            if (i<=100 && i>=0 && boolean == 1) {
+               i--;
+               if(i==0) {
+                    boolean = 0;
+               }
+            } */
+            for (i = 100; i >= 0 ; i--) {
+            Motor1.speed(i*0.01);
+            wait_ms(20);
+            }
+        for (i = 0; i <= 100 ; i++) {
+            Motor1.speed(i*0.01);
+            wait_ms(20);
+            }
+            //Motor1.speed(0.5);
+            
+     n = encoderpin1;
+       if ((encoder0PinALast == 0) && (n == 1)) {
+         if ((encoderpin2) == 0) {
+           encoder0Pos--;
+         } else {
+           encoder0Pos++;
+         }
+         wait_ms(20);
+         pc.printf("%d/n", encoder0Pos);
+       } 
+   encoder0PinALast = n;
+    }
+ }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 19 15:38:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file