Script om de servomotor uit te proberen

Dependencies:   mbed mbed

Revision:
1:acd79b94fe6a
Parent:
0:ebffc70ade24
--- 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