Servo

Dependencies:   mbed MODSERIAL Servo FastPWM

main.cpp

Committer:
s1923196
Date:
2019-10-28
Revision:
8:3990a8c4ccea
Parent:
7:464fb83c8cdf
Child:
10:1754b6220c7a

File content as of revision 8:3990a8c4ccea:

#include "mbed.h"
//#include "Servo.h"
//#include "FastPWM.h"
#include <math.h>
#include "Servo.h"

Serial pc(USBTX, USBRX);
//PwmOut myservo(D5);
//DigitalIn servo_button_pressed(D0);

Servo servo1 (D7); // kan nog aangepast worden de pin
//servo1.Enable(1500,20000);
int pos(); 
int main()
{


while(1) {
     for (int pos = 1000; pos < 2000; pos += 25) {
         servo1.SetPosition(pos);  
         wait_ms(20);
     }
     for (int pos = 2000; pos > 1000; pos -= 25) {
         servo1.SetPosition(pos); 
         wait_ms(20); 
     }
 }
}