// The loop function is called in an endless loop void loop() { #if 0 stepper_int(100); stepper_start(STEPPER_1); stepper_dir(STEPPER_1, 1); delay(6000); stepper_dir(STEPPER_1, 0); for(;;) { digitalWrite(13,HIGH); delay(2000); digitalWrite(13,LOW); delay(2000); } #endif #if 0 while (1) { digitalWrite(13,HIGH); dc_mot_stop(DC_MOT_1); delay(200); dc_mot_start(DC_MOT_1, 1); delay(2000); dc_mot_stop(DC_MOT_1); delay(200); dc_mot_start(DC_MOT_1, 0); delay(2000); dc_mot_stop(DC_MOT_1); digitalWrite(13,LOW); dc_mot_stop(DC_MOT_2); delay(200); dc_mot_start(DC_MOT_2, 1); delay(2000); dc_mot_stop(DC_MOT_2); delay(200); dc_mot_start(DC_MOT_2, 0); delay(2000); dc_mot_stop(DC_MOT_2); } #endif #if 1 //Serial.println("Drop to bzji_loop."); bzji_start(); #endif while (1) ; }
int main(void){ pin_config_out(r_led); Stepper *stepper_x = stepper_init(x_step,x_dir,motor_enb); Stepper *stepper_y = stepper_init(y_step,y_dir,motor_enb); Stepper *stepper_z = stepper_init(z_step,z_dir,motor_enb); //Stepper *stepper_e = stepper_init(e_step,e_dir,motor_enb); stepper_dir(stepper_x,1); stepper_dir(stepper_y,1); stepper_dir(stepper_z,1); a1_step = 180; a2_step = 180; a3_step = 180; //distance = 18000*20; stepper_start_frame(); while(1); }
int main(void) { pin_config_out(g_led); pin_config_out(r_led); pin_config_out(e_heat); pin_config_out(b_heat); pin_config_out(buzzer); pin_low(buzzer); Stepper *stepper_x = stepper_init(x_step,x_dir,motor_enb); Stepper *stepper_y = stepper_init(y_step,y_dir,motor_enb); Stepper *stepper_z = stepper_init(z_step,z_dir,motor_enb); // stepper_start_frame(); Uart *uart = uart_init(); console_init(); thermistor_init(); // console_prompt(); pin_config_in(x_stop); pin_high(r_led); char dir = 1; int count = 0; unsigned int hit = 0; while(1) { // dir = pin_get(EXP2); stepper_dir(stepper_x,dir); stepper_dir(stepper_y,dir); stepper_dir(stepper_z,dir); if(dir == 1) { if(pin_get(x_stop)==0 ) { if(hit < 2) { stepper_step(stepper_x); stepper_step(stepper_y); stepper_step(stepper_z); count++; } } else { hit++; if(hit < 2) { printf("%i\n",count); printf("HIT!\n"); dir = 0; hit = 0; } } } if(dir == 0) { stepper_step(stepper_x); stepper_step(stepper_y); stepper_step(stepper_z); count--; if(count == 0) { dir = 1; } } _delay_us(50); /* count++; if(count == 1000){ pin_toggle(g_led); count = 0; // pin_toggle(stepper_x->direction); // pin_toggle(stepper_y->direction); // pin_toggle(stepper_z->direction); } */ } }