Руслан Урядинский / Mbed 2 deprecated Servo_move_sin

Dependencies:   mbed-STM32F103C8T6 mbed

Revision:
4:2196462a17f5
Parent:
3:ca6028700d1a
Child:
5:e86eda00ef3f
--- a/main.cpp	Tue Apr 10 12:17:46 2018 +0000
+++ b/main.cpp	Tue Apr 10 20:36:08 2018 +0000
@@ -2,8 +2,8 @@
 #include "stm32f103c8t6.h"
 #define val 0.05 // percents in step / 100
 
-PwmOut Servo (PA_8);
-Timeout timer;
+PwmOut Servo (PC_13);
+Ticker timer;
 
 
 double f;
@@ -11,15 +11,16 @@
 
 void sinus (){
     f = (sin((double)i) + 1.0) / 2 + 1; //1..2
-    i += 1;
+    i++;
     if (i > 360) i = 0;
-    Servo = (float)f * val; // duty-cycle, perсents 0..1;
+    Servo = (float)f * val;
 }
 
 int main() {
     confSysClock();
     Servo.period_ms(20);
+    timer.attach(&sinus, 1 / 360); //sine period, sec
     while(1) {
-        timer.attach(&sinus, 1 / 360); //sine period, sec
+         // duty-cycle, perсents 0..1;
     }
 }