Robot C-program for Group B-2 (light), E5 Fall 2002
Michael Cullinan
Masabumi Chano
void back() { motor(0,-100); motor(1,-100); sleep(6.0); } void bumpsensor() { if(digital(8)==0 && digital(7)==0) { back(); motor(0,0); motor(1,50); sleep(4.0); } else if(digital(7)==0){ back(); motor(0,0); motor(1,50); sleep(4.0); } else if(digital(8)==0) { back(); motor(0,50); motor(1,0); sleep(5.0); } } void main() { int found = 0; while (found == 0) { bumpsensor(); printf("\nanalog(4) = %d", analog(4)); printf("analog(5) = %d", analog(5)); if ((analog(5) < 9) && analog(4) < 9) { found = 1; } if ((analog(5)) < (analog(4)-2)) { motor(1,0); motor(0,50); } else if (analog(5) > (analog(4)+2)) { motor(0,0); motor(1,50); } else { motor(0,25); motor(1,25); } } ao(); tone(329.6,.2); sleep(.1); tone(329.6,.2); sleep(.1); tone(329.6,.2); sleep(.1); tone(261.6,.8); sleep(.2); tone(293.7,.2); sleep(.1); tone(293.7,.2); sleep(.1); tone(293.7,.2); sleep(.1); tone(200.0,.8); }