Moottorin ohjaaminen H-sillan avulla Motor control using H-bridge

Dependencies:   microbit

Files at this revision

API Documentation at this revision

Comitter:
tyynetyyne
Date:
Sat Aug 18 14:11:53 2018 +0000
Commit message:
Moottorin ohjaaminen H-sillan avulla

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
microbit.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 61da65a6f0b3 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 18 14:11:53 2018 +0000
@@ -0,0 +1,26 @@
+#include "MicroBit.h"
+
+MicroBit uBit;
+
+int main(){
+    uBit.init();
+    while (1){
+        uBit.io.P1.setDigitalValue(1);
+        uBit.io.P0.setDigitalValue(0);
+        for(int i=0; i<=1023; i=i+20){
+            uBit.io.P2.setAnalogValue(i);
+            uBit.sleep(200);
+        }   
+        uBit.io.P1.setDigitalValue(0);
+        uBit.sleep(500);
+        uBit.io.P0.setDigitalValue(1);
+        for(int i=1023; i>=0; i=i-20){
+            uBit.io.P2.setAnalogValue(i);
+            uBit.sleep(200);
+        }   
+        uBit.io.P0.setDigitalValue(0);
+        uBit.sleep(500);          
+    }
+}
+
+
diff -r 000000000000 -r 61da65a6f0b3 microbit.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/microbit.lib	Sat Aug 18 14:11:53 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Lancaster-University/code/microbit/#4b89e7e3494f