/* * Authors: Ryan Gibson, Paul Ruvolo, Conor Sen * File: TableSweeper.ic * Last Modified: 6 March, 2003 */ // MOTOR locations and their power settings #define L_MOTOR 3 #define R_MOTOR 2 #define L_MOTOR_POWER 38 #define R_MOTOR_POWER 35 // LIGHT SENSOR location and settings // - White paper reads around 12 on the light sensor // - Tabletop is around 18 #define LIGHT 6 #define BOUNDARY 15 // TOUCH SENSOR location #define TOUCH 8 int main() { while (1) { // Move forward until the table boundary is reached or an obstacle // has been hit while( ( analog(LIGHT) > BOUNDARY ) && !digital( TOUCH ) ) { drive( L_MOTOR_POWER, R_MOTOR_POWER ); } /* sleep( 0.25 ); backup( 0.5 ); sleep( 0.25 ); leftTurn(); sleep( 0.25 ); rightTurn(); */ alloff(); } } void drive( int left, int right ) { motor( L_MOTOR, -left ); motor( R_MOTOR, right ); } void backup( float time ) { drive( -L_MOTOR_POWER, -R_MOTOR_POWER ); sleep( time ); stop(); } void leftTurn( ) { drive( -60, 60 ); sleep( .81 ); stop(); } void rightTurn( ) { drive( 60, -60 ); sleep( .87 ); stop(); } void stop( ){ drive( 0, 0 ); }