/* place your #defines and global variable declarations here */ #define height_motor 0 #define height_sensor 0 #define claw_motor 1 #define claw_sensor 7 #define good_speed 80 #define shut 0 #define top 1 #define bot 3 #define sensor 8 #define fast 80 #define slow 40 void program() { int x=2; while 1 { while start_button()==0 {} if (digital(sensor)==x) { tone(500,1); } else{ x=digital(sensor); if x==1 { gorightsideup(); } else { goupsidedown(); } tone(500,3); } } } void gorightsideup() { motor(top,fast); motor(bot,fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,0-fast); motor(bot,0-fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,slow); motor(bot,fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,0-slow); motor(bot,0-fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,fast); motor(bot,slow); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,0-fast); motor(bot,0-slow); sleep(3.0); motor(top,shut); motor(bot,shut); } void goupsidedown() { motor(top,0-fast); motor(bot,0-fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,fast); motor(bot,fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,0-slow); motor(bot,0-fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,slow); motor(bot,fast); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,0-fast); motor(bot,0-slow); sleep(3.0); motor(top,shut); motor(bot,shut); sleep(1.0); motor(top,fast); motor(bot,slow); sleep(3.0); motor(top,shut); motor(bot,shut); } void openclaw() { /* declare your variables here */ /* your program goes here */ while (digital(claw_sensor)==0) { motor (claw_motor, good_speed); } motor(claw_motor, shut); } void height(int height_we_want) { int x=analog(height_sensor); height_we_want=((height_we_want*35)/10)+45; if ((height_we_want>80) || (height_we_want<45)) { beep(); printf("Error: value notbetween 0 - 10\n"); } else { while (height_we_want>analog(height_sensor)) { motor(height_motor,good_speed); } motor(height_motor, shut); while (height_we_want_array_size(choices)) n=_array_size(choices); coarseness=255/(n-1); while(!(stop_button() || start_button())) { selection=(knob())/coarseness; if(selection!=last_selection) { printf("%s\n",choices[selection]); sleep(0.1); last_selection=selection; } } if (start_button()) { return selection * 2 - 1; } else { return selection * 2; } }