Servo controller

Dependencies:   Servo mbed

main.cpp

Committer:
peterknoben
Date:
2017-10-20
Revision:
0:1810c6beabf5

File content as of revision 0:1810c6beabf5:

#include "mbed.h"
#include "Servo.h"

//------------------------------------------------------------------------------
//------------------------------Servo Setup-------------------------------------
//------------------------------------------------------------------------------

Servo MyServo(D9);
InterruptIn But1(PTA4);
int k=0;

//------------------------------------------------------------------------------
//---------------------------Servo Controller-----------------------------------
//------------------------------------------------------------------------------

void servo_control (){
    if (k==0){
        MyServo = 0;
        k=1;
    }
    else{
        MyServo = 2;
        k=0;
        }
}

//------------------------------------------------------------------------------
//-------------------------------Main Loop--------------------------------------
//------------------------------------------------------------------------------

int main()
{
    But1.rise(&servo_control);
    while (1) {}
}