Script voor het aansturen van de motor

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
roosalyn
Date:
Tue Sep 15 09:10:43 2015 +0000
Commit message:
First version to calculate angles for the arms

Changed in this revision

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/main.cpp	Tue Sep 15 09:10:43 2015 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+#include <iostream>
+#include <string>
+#include <math.h>
+
+DigitalOut gpo(D0);
+DigitalOut led(LED_RED);
+
+float bereken_hoeken(float x, float y) {
+    float langste_zijde = sqrt(pow(x*4,2) + pow(y*4,2));
+    float alpha = acos((langste_zijde/2)/30);
+    float beta = 0.5*M_PI - alpha;
+    float hoek_arm2 = 2*beta;
+    float hoek_arm1 = atan((4*y)/(4*x)) + alpha;
+    return hoek_arm2;
+}
+
+int main()
+{   
+    printf("%.2f\n",bereken_hoeken(4,4));
+    printf("%.4f\n",bereken_hoeken(3,7));
+    printf("%.4f\n",bereken_hoeken(5,9));
+    
+    return 0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 15 09:10:43 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file