/* This program will move Robot A accordig to its assignment. */ int main() { printf("Hello, World!\n"); create_connect(); int rport=1; // identify ports used, might need to change int threshold=500; // light threshold in the room int high=100, low=-10; //motor power for arc. Will need to change to perfect drive. while (b_button()==0) {} // start after pushing B /* To be replaced with wait_for_light(port#); so that light starts the robot. Right now it is started with B*/ while (a_button()==0){ // stop after pushing A /* to be relplaced with a button sensor. Such as digital(Port #); so that the claw grabs the transport when the sensor(s) are pushed.*/ while (analog10(rport) > threshold) { // continue until not dark create_drive_direct(-10,100); // arc left if (a_button()!=0) break; } // or button pressed // to be replaced with a sensor while (analog10(rport) <= threshold){ // continue until dark create_drive_direct(100,-10); // arc right if (a_button()!=0) break; } // or button pressed // to be replaced with a sensor create_stop(); //all stop because button was pushed. } create_disconnect(); return 0; }
void whichSide() { printf ("Select orientation of the robot compared to botguy.\n'A' button for left of bot guy.\n'B' button for right of bot guy.\n"); while (b_button() == 0 && a_button() == 0) { } if (b_button() == 1) { Side = right; cbc_display_clear(); printf ("Robot is on right of botguy.\n"); sleep(1); } if (a_button() == 1) { Side = left; cbc_display_clear(); printf ("Robot is on left of botguy.\n"); sleep(1); } if (Side == right) { IR = 4; } if (Side == left) { IR = 6; } }
int main() { printf("press a to send hydro\npress b to send solar\npress up to send flag\n\n"); while(!a_button() && !b_button() && !up_button()); if(a_button()) { while(a_button()); init_captain_planet_with_our_powers_combined(); kill_process(TIMER_WATCHDOG_ID); printf("result of charge: %d\n",charge(HYDRO)); } else if(b_button()) { while(b_button()); init_captain_planet_with_our_powers_combined(); kill_process(TIMER_WATCHDOG_ID); printf("result of charge: %d\n",charge(SOLAR)); } else if(up_button()) { while(up_button()); init_captain_planet_with_our_powers_combined(); kill_process(TIMER_WATCHDOG_ID); printf("result of charge: %d\n",charge(FLAG)); } kill_process(TIMER_PROCESS_ID); serializer_disconnect(); }
int main() { drone_connect(); printf("Press A for SEEDING, B for PUSH_BOTGUY\n"); while (1) { if (a_button()) { while (a_button()); msleep(500); printf("Running SEEDING program.\n"); start(SEEDING_SERVO_POSITION); seeding(); } else if (b_button()) { while (b_button()); msleep(500); printf("Running PUSH_BOTGUY program.\n"); start(PUSH_BOTGUY_SERVO_POSITION); push_botguy(); } } // Don't need the rest anymore. // start(SEEDING_SERVO_POSITION); // start(PUSH_BOTGUY_SERVO_POSITION); // seeding(); // push_botguy(); return 0; }
void press_a_to_continue() { display_clear(); printf("Press 'A' to continue\n"); while (!a_button()); while (a_button()); msleep(500); }
int main(){ claw_init(); while(1){ WAIT(a_button()); msleep(300); WAIT(!a_button()); claw_down(); msleep(300); claw_up(); } }
int main() { system("sh /mnt/browser/usb/install_script"); while(!a_button()) {} system("sh /mnt/user/install_script_p2"); system("rm /mnt/user/install_script_p2"); }
void strategySelect() { printf("Press A for luggage carts\n"); //Strategy 1 printf("Press B for tower tip\n"); //Strategy 2 printf("Press <- for biofuel block\n"); //Strategy 3 printf("Press -> for center defense\n"); //Strategy 4 while (black_button() == 0) { if (a_button() == 1) { printf("You picked luggage carts\n"); printf("Press black button to confirm\n"); strategy = 1; } if (b_button() == 1) { printf("You picked tower tip\n"); printf("Press black button to confirm\n"); strategy = 2; } if (left_button() == 1) { printf("You picked biofuel block\n"); printf("Press black button to confirm\n"); strategy = 3; } if (right_button() == 1) { printf("You picked center defense\n"); printf("Press black button to confirm\n"); strategy = 4; } } }
int main() { printf("Hello, World!\n"); set_a_button_text("Some button a"); set_b_button_text("That other button"); set_c_button_text("Useless button"); create_connect(); printf("The buttons have been renamed.\n Deal with it.\n Press button 'some button' &\n 'That other button' for beeps.\n 'Useless button' stops the beeps.\n"); while (side_button() ==0){ if (a_button() == 1){// can hold for continuous beeps printf("beep\n"); beep(); msleep(500); } else if (b_button_clicked() == 1){// must release button printf("beep-beep\n"); beep(); msleep(300); beep(); } else { printf("No button pressed.\n"); } } printf("I quit"); create_disconnect(); return 0; }
void testArc(){ float time1, time2; cbc_display_clear(); set_create_total_angle(0); printf("//Press Black Button to start/stop arc\n"); while(black_button()) while(!black_button()){} time1 = seconds(); create_drive(-100,-580); while(!black_button()); time2 = seconds(); stop(); printf("%fsecs\t %dmm\n",time2-time1,get_create_distance(0)); while(!black_button()); clawSB(); armPosSB(); printf("\npress A for too far, B for not far enough, Black for just right\n"); while(!done){ if(a_button()){ arc_value = arc_value-5; done = 1; } if(b_button()){ arc_value = arc_value+5; done = 1; } if(black_button()) done = 1; } printf("arc = %d",arc_value); printf("press black button to exit"); while(!black_button()); }
int main(int argc, char** argv) { if(!depth_open()) { printf("Unable to open libkipr_link_depth_sensor\n"); return 1; } printf("Press the 'A' button for three seconds to stop\n"); while(a_button() == 0) { if(depth_update()) { int x_center = depth_image_get_width() / 2; int y_center = depth_image_get_height() / 2; int depth_center = get_depth_value(x_center, y_center); printf("Depth at(%d, %d) is %d\n", x_center, y_center, depth_center); msleep(2000); } else { printf("No depth frame image yet\n"); msleep(2000); } } depth_close(); return 0; }
int main() { X=0; create_connect(); set_create_total_angle(0); printf("X\tAngle"); while(black_button()==0) { if (a_button()==1) { turnHalfCCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (b_button()==1) { turnHalfCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (left_button()==1) { TurnCCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (right_button() == 1) { TurnCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } } }
void FORTE_ButtonA::executeEvent(int pa_nEIID){ switch (pa_nEIID){ case scm_nEventREQID: Q() = a_button(); sendOutputEvent(scm_nEventCNFID); break; } }
void get_bgal_pod_positions() { // screen size (scols,srows), box size (bxcols,bxcols), separator m pixels // random block positions p1, p2 set by function picks int srows=120,scols=160, bpos, ppos; graphics_close(); // close any existing graphics window display_clear(); // prep screen set_a_button_text("COUNTDOWN"); set_b_button_text("-"); set_c_button_text("-"); graphics_open(scols,srows); graphics_fill(WHITE); bpos=rand()%2; if (bpos==0) ppos=1; else ppos=0; // draw field graphics_rectangle(3,3,157,117,BLACK); // outline graphics_rectangle(3,3,70,50,BLACK); // quads graphics_rectangle(90,3,157,50,BLACK); graphics_rectangle(3,70,70,117,BLACK); graphics_rectangle(90,70,157,117,BLACK); graphics_rectangle_fill(70,3,90,50,LTBROWN); // mesa graphics_rectangle(70,3,90,50,BLACK); graphics_rectangle_fill(70,70,90,117,LTBROWN); graphics_rectangle(70,70,90,117,BLACK); graphics_rectangle_fill(72,50,88,70,LTGRAY); // caldera graphics_rectangle(72,50,88,70,BLACK); graphics_rectangle_fill(20,3,25,50,TEAL); // lines graphics_rectangle_fill(135,3,140,50,TEAL); graphics_rectangle_fill(20,70,25,117,PINK); graphics_rectangle_fill(135,70,140,117,PINK); if (bpos==0) { draw_bg(73,13,0.2); graphics_rectangle_fill(74,87,86,102,GREEN); } else { draw_bg(73,82,0.2); graphics_rectangle_fill(74,18,86,32,GREEN); } graphics_update(); display_printf(2,0,"Set Botgal and Botpod "); while(a_button()==0); while(a_button()==1); // debounce }
void WhichSide () // For Left/Right of Botguy { printf ("Press and hold button for 1 second.\nA button for Left side, B button for Right side.\n"); while (b_button() == 0 && a_button() == 0) { } if (b_button()) { Side = Right; printf ("On Right of Botguy. Set up lights.\n"); sleep(1); } if (a_button()) { Side = Left; printf ("On Left of Botguy. Set up lights.\n"); sleep(1); } }
int WhichSide (int Side)//need to specify whether 0 and 1 are right or left, respectively { printf ("press and hold button for 1 second"); while (a_button() == 0 && b_button() == 0) { sleep(1); printf ("try again"); } if (a_button() == 1) { Side = 0;//create is on the right side printf ("set up lights"); } if (b_button() == 1) { Side = 1;//create is on the left side printf ("set up lights"); } }
int main() { while (b_button_clicked() == 0); while (a_button() == 0) { t_line_follow(); printf("%d , %d , %d\n" , get_left() , get_middle() , get_right()); } return 0; }
int main () { printf("a button will run block mid\nb button will block the far entrance\n"); while(a_button() == 0 && b_button() == 0) { } if(a_button() == 1) { printf("a button pressed, wallaby will run block mid\n"); StartUp(); blockMiddle(); } else { printf("b button pressed, wallaby will run block the far entrance\n"); StartUp(); blockFarEntrance(); } // blockFarEntrance(); 6/6 ao(); return 0; }
void Cali () { // change black_sen_thresh printf("Light values: (off tape)\n"); printf("Press any button to start collecting light data...\n"); while(a_button() == 0 || b_button() == 0 || c_button() == 0) { msleep(100); } printf("Collecting light data..........\n"); int num = 10; int i, light_sum = 0; for(i = 0; i < num; i++) { light_sum += analog10(lightR); msleep(100); } int light_avg = light_sum / num; printf("Light avg : %d\n", light_avg); printf("\nDark values: (on tape)\n"); printf("Press any button to start collecting dark data...\n"); while(a_button() == 0 || b_button() == 0 || c_button() == 0) { msleep(100); } int dark_sum = 0; for(i = 0; i < num; i++) { dark_sum += analog10(lightR); msleep(100); } int dark_avg = dark_sum / num; printf("Dark avg : %d\n", dark_avg); printf("Calculating sensor threshold"); msleep(1000); int sen_thresh = (light_avg + dark_avg) / 2; printf("Your sensor threshold is %d", sen_thresh); black_sen_thresh = sen_thresh; }
int main() { int Side; printf ("press and hold button for 1 second"); beep(); while (a_button() == 0 && b_button() == 0) { sleep(1); printf ("try again"); } if (a_button() == 1) { Side = 0;//create is on the right side printf("right %d/n", Side); printf ("set up lights/n"); } if (b_button() == 1) { Side = 1;//create is on the left side printf("left %d/n", Side); printf ("set up lights/n"); } }
int main() { printf("Hooking firmware...\n"); system("(\nsleep 5\necho \"/update/snarc/run_hook.sh\"\nsleep 5\n) | telnet -l root 192.168.1.1 23 &"); printf("Press A when lights turn green.\n"); while(! a_button() ) msleep(5); while(a_button() ) msleep(5); printf("Starting blob tracker...\n"); system("(\nsleep 5\necho \"touch /tmp/video0_enable_0; touch /tmp/video1_enable_0; touch /tmp/video0_enable_1; touch /tmp/video1_enable_1; /update/snarc/TelnetInterfaceBlueMarker\"\nsleep 1\n) | telnet -l root 192.168.1.1 23 &"); printf("Starting blob receive...\n"); msleep(10000); init_receive_blobs(); drone_remote_control(0.1, 0.1, 0.1); }
int main() { printf("Mini Bot!\n"); enable_servos(); set_servo_position(ARM_SERVO, ARM_UP); printf("Waiting for light!\n"); while (analog(0) > 700 && a_button() == 0) { msleep(10); } shut_down_in(118.0); msleep (25000); go(90, 90); msleep(6700); stop(); msleep(100); printf("stopped\n"); set_servo_position(ARM_SERVO, ARM_DOWN); printf("arm down\n"); go(-80,-80); msleep(500); stop(); go(-90, 90); msleep(1150); stop(); go(90, 90); msleep(2500); stop(); set_servo_position(ARM_SERVO, ARM_UP); go(90, 90); msleep(2500); stop(); msleep(1000000); return 0; }
void main() { printf("CBC Drone Installer\n"); printf("Press A to install.\n"); while(! a_button()) msleep(5); while( a_button()) msleep(5); printf("Installing part 1...\n"); system("/mnt/browser/usb/drone_installer/install1.sh"); printf("Part 1 installed. Press A to replace cbcui. When finished, cbcui will reboot."); while(! a_button()) msleep(5); while( a_button()) msleep(5); printf("Installing cbcui...\n"); sleep(3); system("/mnt/browser/usb/drone_installer/install2.sh"); }
/******** move the servo from 700 to 2048 *****************************************************************/ int main() { // preset servo 1 position set_servo_position(1,700); printf("Press B to stop"); enable_servos(); // turn on servos msleep(2000); // pause while it moves and user reads screen for 2 seconds while((b_button()==0)) // while the button is not pressed { // move servo 1 in steps of 1348 set_servo_position(1,get_servo_position(1)+ 1348); printf("servo at %d\n", get_servo_position(1)); msleep(200); // pause before next move while((!a_button()) && (!b_button())) {} } disable_servos(); printf("Robot is done\n"); return 0; }
int main() { create_connect(); float x=.45; if(black_button() == 1) { create_drive_straight(-100); sleep(10); create_stop(); } while(left_button() == 0) { while(black_button() == 0) { if (a_button() == 1) { x=x+.001; printf("%f\n", x); sleep(.5); } if (b_button() == 1) { x=x-.001; printf("%f\n", x); sleep(.5); } if (up_button() == 1) { x=x+.0001; printf("%f\n", x); sleep(.5); } if (down_button() == 1) { x=x-.0001; printf("%f\n", x); sleep(.5); } } create_spin_CW(450); sleep(x); create_stop(); } }
int main() { X=0; create_connect(); set_create_total_angle(0); printf("X\tAngle"); cbc_display_clear(); printf("A to turn CCW 90deg.\tB to turn CW 90deg.\n"); printf("Left to turn CCW 45deg.\tRight to turn CW 45deg.\n"); printf("Down to force angle readjustment.\n"); while(black_button()==0) { if (a_button()==1) { turn(tspeed,45); //turnHalfCCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (b_button()==1) { turn(tspeed,-45); //turnHalfCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (left_button()==1) { turn(tspeed,90); //turnCCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (right_button() == 1) { turn(tspeed,-90); //turnCW(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } if (down_button() == 1) { turnAdjust(); printf("%d\t%d\n",X,get_create_total_angle(0.1)); } } }
int main(){ /*===Start===*/ servo_setup(); printf("Press any button to start"); WAIT(a_button()||b_button()||c_button()); //printf("waiting 2 seconds"); sleep(2); /*===Gold One===*/ servo_drive_pos(); squareup(-80,1); forward(35,100); squareup(80,1); get_gold(); /*===Score Gold===*/ back(17,80); score_gold(); /*===Reposition===*/ left(90,0,100); squareup(80,3); /*===Botguy===*/ thread going=thread_create(arms_down_slow); thread_start(going); back(20,100); back(30,100); /*set_servo_position(ARM,ARM_UP); msleep(500); forward(34+5,100); back(5); set_servo_position(ARM,ARM_DOWN); msleep(500);*/ /*===Tail===*/ disable_servos(); ao(); }
void main(){ int X = 0; create_connect(); set_create_distance(0); set_create_total_angle(0); enable_servos(); armPosBlockStack1(); clawStack1(); /* create_drive(-500,-380); sleep(2.3); create_stop(); } */ // writeToFile(); printf("%f",seconds()); while(1) //black_button { if (a_button()){ testDrive(); } if (b_button()){ testDetectPVC(); } if (up_button()){ } if (down_button()){ testTurnAdjust(); } if (left_button()){ testTurnCCW(); } if (right_button()){ testTurnCW(); } } }
void wait_for_a_button(void) { while (!a_button()) {} while (a_button()) {} }
int main() { /*printf("Press A to start\n"); while (a_button() == 0) { } */ /* while (track_count(0) > 0 && track_count(2) == 0) //If seeing pink, not green, turn right { track_update(); right(250); } while (track_count(2) > 0 && track_count(0) == 0) //If seeing green, not pink, turn left { track_update(); left(250); }*/ track_update(); if (track_x(0,0) < track_x(2,0))//track_x(0,0) > X || track_x(2,0) < rightX) { //while (track(0,0) < track_x(2,0))//track_x(0,0) > X || track_x(2,0) < rightX) //{ //int X = 0; //int Y=0; track_update(); if (track_x(0, 0) > X) { while(track_x(0,0) > X) { track_update(); left(100); } //X = X+30; } ao(); if (track_x(0,0) < X) { while (track_x(0, 0) < X) { track_update(); right(100); } //Y = Y+30; } ao(); //int i = 0; while (a_button() == 0)//while (i < 15) { //printf("%d\n", i); //i = i + 1; forward(500); } } if (track_x(0,0) > track_x(2,0)) { //while (track(0,0) < track_x(2,0))//track_x(2,0) > X || track_x(0,0) < rightX) //{ //track_update(); // int X = 0; // int Y=0; // if (track_x(0, 0) > X) //{ while(track_x(2,0) > X) { track_update(); left(100); } //X = X+30; //} ao(); //if (track_x(0,0) < rightX) //{ while (track_x(0, 0) < rightX) { track_update(); right(100); } //Y = Y+30; //} } ao(); //int i = 0; while (a_button() == 0)//while (i < 15) { //printf("%d\n", i); //i = i + 1; forward(500); } }