#define FeedMotor OUT_A #define DiskSense SENSOR_1 #define FeedPos SENSOR_2 task main () { int DiskPresent; SetSensor (FeedPos, SENSOR_TOUCH); SetSensor (DiskSense, SENSOR_LIGHT); DiskPresent = DiskSense - 5; // get ambient light OnFwd (OUT_B+OUT_C); // start wheels motors Wait(1500); // and wait for spee up while (DiskSense > DiskPresent) { FeedDisk(); // Launch disks while they last } Off (OUT_B+OUT_C); PlaySound (SOUND_FAST_UP); } sub FeedDisk () { OnRev (FeedMotor); //Start launch carriage until (FeedPos == 0); //Wait till no rear contact Wait(10); until (FeedPos == 1); //Wait till front contact OnFwd (FeedMotor); //restore launch carriage until (FeedPos == 0); //Wait till no front contact Wait(10); until (FeedPos == 1); //Wait till rear contact Off (FeedMotor); }