Dependencies:   Servo mbed

Committer:
jderemer3
Date:
Wed Mar 01 16:48:56 2017 +0000
Revision:
0:153d4d641769

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jderemer3 0:153d4d641769 1 // Hello World to sweep a servo through its full range
jderemer3 0:153d4d641769 2
jderemer3 0:153d4d641769 3 #include "mbed.h"
jderemer3 0:153d4d641769 4 #include "Servo.h"
jderemer3 0:153d4d641769 5
jderemer3 0:153d4d641769 6 Servo myservo(p22);
jderemer3 0:153d4d641769 7
jderemer3 0:153d4d641769 8 int main() {
jderemer3 0:153d4d641769 9 int s = 0;
jderemer3 0:153d4d641769 10 while (1)
jderemer3 0:153d4d641769 11 {
jderemer3 0:153d4d641769 12 if (s = 0)
jderemer3 0:153d4d641769 13 {
jderemer3 0:153d4d641769 14 for(float p=0; p<1.0; p += 0.1)
jderemer3 0:153d4d641769 15 {
jderemer3 0:153d4d641769 16 myservo = p;
jderemer3 0:153d4d641769 17 wait(0.4);
jderemer3 0:153d4d641769 18 }
jderemer3 0:153d4d641769 19 s = 1;
jderemer3 0:153d4d641769 20 }
jderemer3 0:153d4d641769 21 else if (s = 1)
jderemer3 0:153d4d641769 22 {
jderemer3 0:153d4d641769 23 for(float p=1; p>0.0; p -= 0.1)
jderemer3 0:153d4d641769 24 {
jderemer3 0:153d4d641769 25 myservo = p;
jderemer3 0:153d4d641769 26 wait(0.4);
jderemer3 0:153d4d641769 27 }
jderemer3 0:153d4d641769 28 s = 0;
jderemer3 0:153d4d641769 29 }
jderemer3 0:153d4d641769 30 }
jderemer3 0:153d4d641769 31 }