Gets user Input to turn the servo to certain degrees

Dependencies:   mbed

servo.cpp

Committer:
hzelayasolano22
Date:
2019-01-13
Revision:
2:9d9717796ab2
Child:
3:5b6a55afc60a

File content as of revision 2:9d9717796ab2:

#include "servo.h"
PwmOut servo(p21);

void setServo();
    servo.period(0.020);
    servo.pulsewidth_us(1500);
    wait(2);
    }
    
void moveServo(char a){
    switch(a){
        case 1: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 2: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 3: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 4: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 4: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 5: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 6: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 7: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 8: servo.pulsdewidth_us(pulsewidth(-90)); break;
        case 9: servo.pulsdewidth_us(pulsewidth(-90)); break;
        }
    
    
    
    }