A simple test program to test the Servo library.

Dependencies:   mbed Servo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Keep sweeping servo from left to right
00002 #include "mbed.h"
00003 #include "Servo.h"
00004 
00005 Servo Servo1(p20);
00006 
00007 int main() {
00008     Servo1.Enable(1000,20000);
00009     while(1) {
00010         for (int pos = 1000; pos < 2000; pos += 25) {
00011             Servo1.SetPosition(pos);
00012             wait_ms(20);
00013         }
00014         for (int pos = 2000; pos > 1000; pos -= 25) {
00015             Servo1.SetPosition(pos); 
00016             wait_ms(20);
00017         }
00018     }
00019 }