heres the code
Dependencies: Motor Servo mbed
Diff: main.cpp
- Revision:
- 0:e8eaa22280a2
- Child:
- 2:e43e3a2eb025
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 09 14:12:58 2018 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "stdio.h" +#include "Motor.h" +#include "Servo.h" + +Servo gate(p22); +Servo celly(p21); +int i; +float x; +int j=1; + +int main() { + while (1) { + gate.calibrate(0.0009, 90.0); + celly.calibrate(0.0009, 90.0); + gate = 0.5; //set gate to halfway point + x = (rand()%9)+1; + if (x <= 7) { + gate = 1.0; //gate has a 70% chance to go one way + wait (1.5); //gives time for crab to get down track and begin navy celebration + for (i=0; i<=1;i++) { + celly = -j; + } + } + else { //30% chance the gate will go the other way + gate = 0.0; } + } + } \ No newline at end of file