Gun Trigger Code

Dependencies:   Servo mbed

main.cpp

Committer:
vinnypotente
Date:
2018-10-15
Revision:
1:45d7c2476250
Parent:
0:e65fc2ec46d6

File content as of revision 1:45d7c2476250:

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

Servo myservo(p21);
float pos;
char c;
int main()
{
    myservo.calibrate(0.0009,90.0);
    myservo=0.0;
    wait(1);
    while (1) {
        c = getchar ();//prompts the arm to pull the trigger
        for (pos =0.0; pos<=10.0; pos=pos+10.0) {
            myservo=(pos/10.0);
            wait (0.07);
            printf("%f\n",pos);
        }
        for (pos =10.0; pos>=0.0; pos=pos-10.0) {
            myservo=(pos/10.0);
            wait (0.07);
            printf("%f\n",pos); // pulls the trigger
        }
    }
}