ECE 4180 Lab 2 Part 9

Dependencies:   Servo mbed

Fork of Servo_HelloWorld by Simon Ford

Committer:
abraha2d
Date:
Tue Oct 09 00:50:21 2018 +0000
Revision:
2:4609f408d050
Parent:
1:40d2fd0b99e6
Save point

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 1:40d2fd0b99e6 1 // Hello World to sweep a servo through its full range
simon 1:40d2fd0b99e6 2
simon 1:40d2fd0b99e6 3 #include "mbed.h"
simon 1:40d2fd0b99e6 4 #include "Servo.h"
simon 1:40d2fd0b99e6 5
simon 1:40d2fd0b99e6 6 Servo myservo(p21);
simon 1:40d2fd0b99e6 7
abraha2d 2:4609f408d050 8 int main()
abraha2d 2:4609f408d050 9 {
abraha2d 2:4609f408d050 10 while (1) {
abraha2d 2:4609f408d050 11 for(float p=0; p<1.0; p += 0.1) {
abraha2d 2:4609f408d050 12 myservo = p;
abraha2d 2:4609f408d050 13 wait(0.2);
abraha2d 2:4609f408d050 14 }
abraha2d 2:4609f408d050 15 for(float p=1.0; p>0; p -= 0.1) {
abraha2d 2:4609f408d050 16 myservo = p;
abraha2d 2:4609f408d050 17 wait(0.2);
abraha2d 2:4609f408d050 18 }
simon 1:40d2fd0b99e6 19 }
simon 1:40d2fd0b99e6 20 }