Script om de servomotor uit te proberen

Dependencies:   mbed mbed

Files at this revision

API Documentation at this revision

Comitter:
lisa96m
Date:
Thu Oct 20 10:08:47 2016 +0000
Parent:
0:ebffc70ade24
Commit message:
Try out servo;

Changed in this revision

Servo.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Servo.lib	Thu Oct 20 07:31:33 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07
--- a/main.cpp	Thu Oct 20 07:31:33 2016 +0000
+++ b/main.cpp	Thu Oct 20 10:08:47 2016 +0000
@@ -5,25 +5,25 @@
 Serial pc(USBTX, USBRX);
 
 PwmOut servo(A4);
-double x = 0;
-float pi = 3.14;
-
+volatile double x = 0;
 
 void loop()
 {
     double y = sin(x);
     {
-        x++;
+        x = x+0.2;
     }
     servo = abs(y);
     pc.printf("grootte van sinus is %f.\r\n", abs(y));
+    pc.printf("grootte van x is %f.\r\n", x);
 }
 
 int main()
 {
     pc.baud(SERIAL_BAUD);
+    servo.period(0.020);
     while(true) {
         loop();
-        wait(10);
+        wait(2);
     }
 }
\ No newline at end of file