Shows a lab where we can servo motor move from left to right and right to left

Dependencies:   Servo mbed

Committer:
EduRemo
Date:
Fri Feb 05 07:28:18 2016 +0000
Revision:
0:3d38b95d74a0
FRCRCE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EduRemo 0:3d38b95d74a0 1 // Hello World to sweep a servo through its full range
EduRemo 0:3d38b95d74a0 2
EduRemo 0:3d38b95d74a0 3 #include "mbed.h"
EduRemo 0:3d38b95d74a0 4 #include "Servo.h"
EduRemo 0:3d38b95d74a0 5
EduRemo 0:3d38b95d74a0 6 Servo myservo(PTC1);
EduRemo 0:3d38b95d74a0 7
EduRemo 0:3d38b95d74a0 8
EduRemo 0:3d38b95d74a0 9 int main() {
EduRemo 0:3d38b95d74a0 10 while(1) {
EduRemo 0:3d38b95d74a0 11 for(int i=0; i<=100; i++) {
EduRemo 0:3d38b95d74a0 12 myservo = i/100.0;
EduRemo 0:3d38b95d74a0 13 wait(0.1);
EduRemo 0:3d38b95d74a0 14 }
EduRemo 0:3d38b95d74a0 15 for(int i=99; i>=0; i--) {
EduRemo 0:3d38b95d74a0 16 myservo = i/100.0;
EduRemo 0:3d38b95d74a0 17 wait(0.1);
EduRemo 0:3d38b95d74a0 18 }
EduRemo 0:3d38b95d74a0 19 }
EduRemo 0:3d38b95d74a0 20 }