Dependencies:   Servo mbed

main.cpp

Committer:
jderemer3
Date:
2017-03-01
Revision:
0:153d4d641769

File content as of revision 0:153d4d641769:

// Hello World to sweep a servo through its full range
 
#include "mbed.h"
#include "Servo.h"
 
Servo myservo(p22);
 
int main() {    
    int s = 0;
    while (1)
    {
        if (s = 0)
        {
            for(float p=0; p<1.0; p += 0.1)
            {
                myservo = p;
                wait(0.4);
            }
            s = 1;
        }
        else if (s = 1)
        {
            for(float p=1; p>0.0; p -= 0.1)
            {
                myservo = p;
                wait(0.4);
            }
            s = 0;
        }
    }
}