Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Motor Servo mbed
main.cpp
00001 #include "mbed.h" 00002 #include "stdio.h" 00003 #include "Motor.h" 00004 #include "Servo.h" 00005 #include "time.h" 00006 00007 Motor knife(p26, p30, p29); 00008 Servo finish(p22); 00009 Servo start(p21); 00010 DigitalOut led[4]={LED1, LED2, LED3, LED4}; 00011 int i, j; 00012 int x; 00013 00014 00015 int main() { 00016 start.calibrate(0.0009, 90.0); 00017 finish.calibrate(0.0009, 90.0); 00018 00019 start = 0.25; //lowers start gate 00020 wait (1.0); //gives time for crab to get down track 00021 00022 x = (rand()%9)+1; 00023 printf("%d", x); 00024 00025 start = 0.0; //set initial start gate position 00026 00027 00028 if (x <= 7) { 00029 finish = 1.0; //gate has a 70% chance to go one way 00030 for (i=0; i<5; i++) { 00031 led[i] = 1; 00032 wait (0.15); 00033 led[i]=0; 00034 } 00035 } 00036 else { //30% chance the gate will go the other way 00037 finish = 0.0; 00038 knife.speed (0.5); 00039 wait (.5); 00040 knife.speed (-0.5); 00041 wait (.5); 00042 knife.speed(0); 00043 } 00044 00045 finish = 0.5; //set finish gate to halfway point 00046 00047 00048 }
Generated on Sun Jul 17 2022 20:02:32 by
1.7.2