heres the code

Dependencies:   Motor Servo mbed

main.cpp

Committer:
JackTamas
Date:
2018-10-09
Revision:
2:e43e3a2eb025
Parent:
0:e8eaa22280a2
Child:
3:4243b540714d

File content as of revision 2:e43e3a2eb025:

#include "mbed.h"
#include "stdio.h"
#include "Motor.h"
#include "Servo.h"

Servo finish(p22);
Servo start(p21);
int i;
float x;
    
int main() {
        while (1) {
        finish.calibrate(0.0009, 90.0);
        start.calibrate(0.0009, 90.0);
        finish = 0.5; //set gate to halfway point
        x = (rand()%9)+1;
        if (x <= 7) {
            finish = 1.0; //gate has a 70% chance to go one way
            wait (1.0); //gives time for crab to get down track 
            else { //30% chance the gate will go the other way 
                gate = 0.0; }
                }       
        }