Casper Kroon / Mbed 2 deprecated EMG_Motor_LED

Dependencies:   HIDScope MODSERIAL mbed

Fork of EMG_Motor_LED by Michel Vos

Files at this revision

API Documentation at this revision

Comitter:
CasperK
Date:
Tue Sep 25 12:31:41 2018 +0000
Child:
1:aa505856416d
Commit message:
First try of combination of turning motor and sending potmeter value to HIDscope

Changed in this revision

HIDScope.lib Show annotated file Show diff for this revision Revisions of this file
MODSERIAL.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/HIDScope.lib	Tue Sep 25 12:31:41 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/tomlankhorst/code/HIDScope/#d23c6edecc49
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Tue Sep 25 12:31:41 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#a3b2bc878529
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 25 12:31:41 2018 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+#include "HIDScope.h"
+
+PwmOut pwmpin(D6);
+PwmOut led(D10);
+AnalogIn potmeter(A5);
+DigitalIn button(D2);
+DigitalOut directionpin(D5);
+
+HIDScope scope(2);
+Ticker ticker;
+
+volatile float x;
+volatile float y;
+volatile float x_prev;
+
+void sendData() {
+    scope.set(0,potmeter); //set the potmeter data to the first scope
+//    scope.set(1,x);
+    scope.send();
+}
+
+int main() {  
+    float u = -0.3f; //determineusefulvalue, -0.3f is justanexample
+//    x = 1;
+    
+    pwmpin.period_us(60); //60 microsecondsPWM period, 16.7 kHz
+    led.period(0.00001); //10kHz
+    ticker.attach(&sendData, 0.001f); //send data to hidscope at 1kHz
+    directionpin= u > 0.0f; //eithertrueor false   
+
+    while (true) {
+        pwmpin.write(potmeter); //pwm of motor is potmeter value
+        led.write(potmeter); //led is potmeter value
+        wait(0.2f);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 25 12:31:41 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file