void draw_my_name() { pen_colour(BLACK); pen_down(); turn(RIGHT); forward(100); turn(LEFT); forward(200); turn(LEFT); forward(100); pen_up(); forward(-50); turn(LEFT); pen_down(); forward(200); pen_up(); turn(LEFT); forward(100); turn(LEFT); forward(100); turn(180); pen_down(); forward(100); turn(LEFT); forward(50); turn(LEFT); forward(100); pen_up(); turn(RIGHT); forward(50); pen_down(); forward(50); turn(RIGHT); forward(100); turn(RIGHT); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(50); pen_up(); forward(50); turn(RIGHT); forward(50); turn(180); pen_down(); forward(100); turn(RIGHT); forward(50); turn(RIGHT); forward(100); pen_up(); }
void keyPressed() { if(keyCode==UP) send_command(FORWARD, linear_parameter1, linear_parameter2); if(keyCode==DOWN) send_command(BACKWARD, linear_parameter1, linear_parameter2); if(keyCode==LEFT) send_command(right, rotary_parameter1, rotary_parameter2); if(keyCode==RIGHT) send_command(left, rotary_parameter1, rotary_parameter2); if(key=='c') { for(int i=0;i<100;i++) { send_command(FORWARD,linear_parameter1,linear_parameter2); delay(1000); send_command(left, rotary_parameter1, rotary_parameter2); delay(1000); if(pen) { pen_up(); } else pen_down(); pen=!pen; delay(750); check_data(); } } if(key=='?') { send_query(GET_STATUS); } if(key=='q') { exit(); } if(key=='u') pen_up(); if(key=='d') pen_down(); if(key==' ') send_command(STOP,(byte)0,(byte)0); // if(key==' ') // send_stop(); }
void turn_left(int degree){ pen_up(); _delay_ms(100); move_straight(245,1); left_degrees(degree); move_straight(245,0); _delay_ms(100); pen_down(); }
int main(int argc, char* argv[]) { srand(time(0)); create_turtle_world(); pen_up(); forward(-150); pen_down(); draw_tree(300, 5); return p1world_shutdown(); }
//This function is used to draw different size of triangles in different colours. void draw_triangle(int scale) { pen_colour(NEXT); pen_down(); forward(10 * scale); turn(105); forward(5 * scale); turn(105); forward(10 * scale); turn(180); pen_up(); }
//Main function int main(void) { //Initialize value array with 0 int i; for(i=0;i<1000;i++){ val_array[i] = 0; } data_pos = 0; bot_pos = 0; init_devices(); //LCD_Reset_4bit(); lcd_cursor(2,1); lcd_string("DRAWOID"); while(1){ if (bot_pos < data_pos){ lcd_print(1,9,val_array[bot_pos],3); lcd_cursor(1,1); if (mov_array[bot_pos] == 'F'){ lcd_string("F"); move_straight(val_array[bot_pos],1); } else if (mov_array[bot_pos] == 'B'){ lcd_string("B"); move_straight(val_array[bot_pos],0); } else if (mov_array[bot_pos] == 'R'){ lcd_string("R"); turn_right(val_array[bot_pos]); } else if (mov_array[bot_pos] == 'L'){ lcd_string("L"); turn_left(val_array[bot_pos]); } else if (mov_array[bot_pos] == 'U'){ lcd_string("U"); pen_up(); } else if (mov_array[bot_pos] == 'D'){ lcd_string("D"); pen_down(); } bot_pos++; _delay_ms(1000); } } return 0; }
int main(int argc, char* argv[]) { set_delay_time(1); create_turtle_world(); pen_up(); turn(LEFT); forward(200); turn(RIGHT); draw_my_name(); hide_turtle(); return(p1world_shutdown()); }
int main(void) { setSysTick(); config_PWM(); gpio_init_motor(); pen_up(); pad_init(); draw(); /* Create a task to button check. */ //xTaskCreate(H1,(signed portCHAR *) "AutoWrite", 512, NULL, tskIDLE_PRIORITY + 4, NULL ); /* Start running the tasks. */ //vTaskStartScheduler(); while(1); }
int main(int argc, char* argv[]) { create_turtle_world(); turn(90); for (int i = 0; i < 7; i++) { forward(20); pen_up(); if (i < 6) { forward(20); } pen_down(); } hide_turtle(); return p1world_shutdown(); }
int main() { char keyboard_input[100]; XColor black_col,white_col,red_col,green_col,blue_col,yellow_col,magenta_col,cyan_col; Colormap colormap; char black_bits[] = "#000000"; char white_bits[] = "#FFFFFF"; // Mix red, green and blue to get white char red_bits[] = "#FF0000"; char green_bits[] = "#00FF00"; char blue_bits[] = "#0000FF"; char yellow_bits[] = "#FFFF00"; // Mix red and green to get yellow char magenta_bits[] = "#FF00FF"; // A sort of purple color char cyan_bits[] = "#00FFFF"; // A blue-green color //Display *dpy = XOpenDisplay(NIL); dpy = XOpenDisplay(NIL); assert(dpy); // Open the display // Define the colors we want to use colormap = DefaultColormap(dpy, 0); XParseColor(dpy, colormap, black_bits, &black_col); XAllocColor(dpy, colormap, &black_col); XParseColor(dpy, colormap, white_bits, &white_col); XAllocColor(dpy, colormap, &white_col); XParseColor(dpy, colormap, red_bits, &red_col); XAllocColor(dpy, colormap, &red_col); XParseColor(dpy, colormap, green_bits, &green_col);XAllocColor(dpy, colormap, &green_col); XParseColor(dpy, colormap, blue_bits, &blue_col);XAllocColor(dpy, colormap, &blue_col); XParseColor(dpy, colormap, yellow_bits, &yellow_col);XAllocColor(dpy, colormap, &yellow_col); XParseColor(dpy, colormap, magenta_bits, &magenta_col);XAllocColor(dpy, colormap, &magenta_col); XParseColor(dpy, colormap, cyan_bits, &cyan_col);XAllocColor(dpy, colormap, &cyan_col); // Create the window The numbers are the x and y locations on the screen, the width and height, // border width (which is usually zero) w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, window_width, window_height, 0, black_col.pixel, black_col.pixel); XSelectInput(dpy, w, StructureNotifyMask); // We want to get MapNotify events XMapWindow(dpy, w); // "Map" the window (that is, make it appear on the screen) for(;;){XEvent e; XNextEvent(dpy,&e); if(e.type == MapNotify) break;} //Wait for the MapNotify event // which means that the window has appeared on the screen. gc = XCreateGC(dpy, w, 0, NIL); // Create a "Graphics Context" get_pen(white_col); // We are finally ready to do some drawing! Whew! // ................ Students: you put your beautiful code HERE: ....................... int i; home(); // Send the turtle to the middle of the window. That's its "home" get_pen(green_col); for (i=0; i<36; i++) { forward(250); //printf("1 x=%g y=%g heading=%g\n",turtle_x,turtle_y,turtle_heading); //Optional: use for debugging right(170); //usleep(100000); XFlush(dpy); // Optional: use this to see the lines being drawn, one-by-one } pen_up(); home(); left(90); pen_down(); for (i=0; i<4; i++) { get_pen(cyan_col); forward(200); //printf("2 x=%g y=%g heading=%g\n",turtle_x,turtle_y,turtle_heading); //Optional: use for debugging left(90); } XFlush(dpy); // Tell the graphics server that it should really show us the results now. sleep(1); // Wait for 1 second printf("Press enter when done.\n"); fgets (keyboard_input,100,stdin); return(0); }
void next() { pen_up(); forward(55); pen_down(); }
void cmd_interpreter( void *xBoard,int pressed_key) { // ================================================ //printf("I am inside cmd_interpreter() before switch. \n"); switch (pressed_key) { case 117: // pressed_key char = u or int = 117 // DRIVE CNC ALONG Y-AXIS printf("u \tdrive_up (500) y-axis (12,8 CW)\t==> Y-axis PINS = (0)(0) (1/0)(1) (0)(0) running ... "); drive_up(xBoard, 500); // DRIVE (12,8 CW) printf("done.\n"); break; case 100: // pressed_key char = d or int = 100 // DRIVE CNC ALONG Y-AXIS printf("d \tdrive_down (500) y-axis (4,0 CCW)\t==> Y-axis PINS = (0)(0) (1)(0) (0)(0) running ... "); drive_down(xBoard, 500); // DRIVE (4,0 CCW) printf("done.\n"); break; case 114: // pressed_key char = r or int = 114 // DRIVE CNC ALONG X-AXIS printf("r \tdrive_right (500) x-axis (3,2 CW)\t==> X-axis PINS = (1/0)(1) (0)(0) (0)(0) running ... "); drive_right(xBoard, 500); // DRIVE (3,2 CW) printf("done.\n"); break; case 108: // pressed_key char = l or int = 108 // DRIVE CNC ALONG X-AXIS printf("l \tdrive_left (500) x-axis (1,0 CCW)\t==> X-axis PINS = (1)(0) (0)(0) (0)(0) running ... "); drive_left(xBoard, 500); // DRIVE (1,0 CCW) printf("done.\n"); break; case 122: // pressed_key char = z or int = 122 // DRIVE CNC ALONG Z-AXIS printf("z \tdrivepen_up (500) z-axis (16,0 CW)\t==> Z-axis PINS = (0)(0) (0)(0) (1)(0) running ... "); pen_up(xBoard, 500); // DRIVE (16,0 CW) printf("done.\n"); break; case 115: // pressed_key char = s or int = 115 // DRIVE CNC ALONG Z-AXIS printf("s \tdrivepen_down(500) z-axis (48,32 CCW)\t==> Z-axis PINS = (0)(0) (0)(0) (1/0)(1) running ... "); pen_down(xBoard, 500); // DRIVE (48,32 CCW) printf("done.\n"); break; //=========== case 113: // pressed_key char = q or int = 113 // QUIT AND EXIT PROGRAM printf("q \tQuit and exit. \t\t==> Alhamdulillah. Done. \n\n"); // reset_CNC(); // RELEASE IO_PORTADDRESS WITH VALUE 0 printf("Alhamdulillah. Parallel port successfully released. \n\n"); close_keyboard(); exit(0); default: printf("%c \tERROR: Invalid command: ==> char %c or int %d \n", pressed_key, pressed_key, pressed_key); } //printf("I am exiting cmd_interpreter() after switch. \n"); }
int main(int argc, char* argv[]) { create_turtle_world(); pen_up(); forward(200); turn(LEFT); forward(400); turn(LEFT); forward(100); turn(180); pen_down(); pen_colour(BLACK); forward(100); turn(RIGHT); forward(50); turn(RIGHT); forward(100); forward(-50); turn(RIGHT); forward(50); forward(-50); turn(RIGHT); forward(50); turn(RIGHT); pen_up(); forward(25); pen_down(); turn(RIGHT); forward(100); turn(LEFT); forward(50); turn(LEFT); forward(100); turn(RIGHT); pen_up(); forward(25); pen_down(); forward(100); forward(-50); turn(RIGHT); forward(100); pen_up(); forward(50); turn(RIGHT); forward(200); pen_down(); pen_colour(MAGENTA); turn(LEFT); forward(100); forward(-100); turn(LEFT); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(50); turn(-135); forward(70); pen_up(); forward(-70); turn(-45); forward(75); pen_down(); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(25); turn(RIGHT); forward(50); pen_up(); forward(75); turn(LEFT); forward(25); turn(LEFT); pen_down(); forward(50); turn(LEFT); forward(25); turn(LEFT); forward(50); turn(RIGHT); forward(25); turn(RIGHT); forward(50); pen_up(); forward(-75); turn(LEFT); forward(50); turn(180); pen_down(); forward(100); turn(RIGHT); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(50); pen_up(); turn(RIGHT); forward(100); turn(RIGHT); forward(75); turn(RIGHT); pen_down(); forward(100); turn(LEFT); forward(50); turn(LEFT); forward(50); turn(LEFT); forward(50); pen_up(); forward(-125); turn(LEFT); forward(50); turn(RIGHT); pen_down(); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(25); turn(RIGHT); forward(50); pen_up(); forward(-75); turn(LEFT); forward(25); turn(180); pen_down(); forward(50); turn(RIGHT); forward(50); pen_up(); forward(25); turn(RIGHT); forward(50); turn(180); pen_down(); forward(50); turn(RIGHT); forward(50); pen_up(); forward(25); turn(RIGHT); pen_down(); forward(50); turn(LEFT); forward(50); turn(LEFT); forward(50); forward(-100); turn(LEFT); forward(50); pen_up(); forward(-150); turn(RIGHT); forward(50); pen_down(); pen_colour(GREEN); forward(100); turn(RIGHT); forward(50); turn(RIGHT); forward(50); turn(RIGHT); forward(50); pen_up(); forward(-75); turn(LEFT); pen_down(); forward(50); pen_up(); turn(180); forward(70); pen_down(); forward(10); pen_up(); hide_turtle(); return (p1world_shutdown()); }