Thijs Rakels / Mbed 2 deprecated Encoders

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Thijsjeee
Date:
Tue Sep 25 15:48:29 2018 +0000
Commit message:
hoi;

Changed in this revision

Encoders.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 fb2b540167a8 Encoders.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Encoders.cpp	Tue Sep 25 15:48:29 2018 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+#include <math.h>
+
+
+DigitalOut Led1(D5);
+DigitalOut Led2(D4);
+DigitalIn  B(D2);
+DigitalIn  A(D3);
+Ticker check;
+Ticker printer;
+volatile int prev_A;
+volatile int prev_B;
+int state = 0;
+
+
+void Printer()
+{
+printf("%i\r\n",state);
+}
+
+
+void Checker ()
+{
+   if (prev_A == 1)
+   {
+       if(A == 0)
+       {
+       ++state;
+       }
+    }
+    if (prev_A == 0)
+   {
+       if(A == 1)
+       {
+       ++state;
+       }
+    }
+    prev_A = A;
+    
+    
+    if (prev_B == 1)
+   {
+       if(B == 0)
+       {
+       ++state;
+       }
+    }
+    if (prev_B == 0)
+   {
+       if(B == 1)
+       {
+       ++state;
+       }
+    }
+    prev_B = B;
+}
+
+
+
+
+main()
+{
+    printer.attach(Printer, 0.1);
+    check.attach(Checker, 1e-6);
+    prev_A = A;
+    prev_B = B;
+    while(true)
+    {
+    }     
+}
\ No newline at end of file
diff -r 000000000000 -r fb2b540167a8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 25 15:48:29 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/675da3299148
\ No newline at end of file