Example code for 'Mechatronics Class'

Revision:
2:83a817de162e
Parent:
0:8c7b073576c5
diff -r 49002ccc54b5 -r 83a817de162e main.cpp
--- a/main.cpp	Fri Jun 23 16:15:38 2017 -0500
+++ b/main.cpp	Mon Oct 14 02:35:03 2019 +0000
@@ -1,29 +1,18 @@
 #include "mbed.h"
-
-class Counter {
-public:
-    Counter(PinName pin) : _interrupt(pin) {        // create the InterruptIn on the pin specified to Counter
-        _interrupt.rise(callback(this, &Counter::increment)); // attach increment function of this counter instance
-    }
+#include "counter.h"
 
-    void increment() {
-        _count++;
-    }
-
-    int read() {
-        return _count;
-    }
-
-private:
-    InterruptIn _interrupt;
-    volatile int _count;
-};
-
-Counter counter(SW2);
+PwmOut pwm(D10);    // wire to tie D10, D12, and D13(LED1)
+DigitalIn led(LED1);
 
 int main() {
+    Counter count(D12);
+    count = 0;
+
+    pwm.period(0.1);
+    pwm = 0.5;
+
     while(1) {
-        printf("Count so far: %d\n", counter.read());
-        wait(2);
+        printf("Count so far: %d\n", int(count));
+        wait(1);
     }
 }
\ No newline at end of file