void soft_left_2_degrees(unsigned int Degrees) { // 176 pulses for 360 degrees rotation 2.045 degrees per count soft_left_2(); //Turn reverse soft left Degrees=Degrees*2; angle_rotate(Degrees); }
//Main Function int main() { init_devices(); velocity (100, 100); //Set robot velocity here. Smaller the value lesser will be the velocity //Try different valuse between 0 to 255 while(1) { forward(); //both wheels forward _delay_ms(1000); stop(); _delay_ms(500); back(); //both wheels backward _delay_ms(1000); stop(); _delay_ms(500); left(); //Left wheel backward, Right wheel forward _delay_ms(1000); stop(); _delay_ms(500); right(); //Left wheel forward, Right wheel backward _delay_ms(1000); stop(); _delay_ms(500); soft_left(); //Left wheel stationary, Right wheel forward _delay_ms(1000); stop(); _delay_ms(500); soft_right(); //Left wheel forward, Right wheel is stationary _delay_ms(1000); stop(); _delay_ms(500); soft_left_2(); //Left wheel backward, right wheel stationary _delay_ms(1000); stop(); _delay_ms(500); soft_right_2(); //Left wheel stationary, Right wheel backward _delay_ms(1000); stop(); _delay_ms(1000); } }
//Main Function int main() { init_devices(); while(1) { forward(); //both wheels forward _delay_ms(1000); stop(); _delay_ms(500); back(); //bpth wheels backward _delay_ms(1000); stop(); _delay_ms(500); left(); //Left wheel backward, Right wheel forward _delay_ms(1000); stop(); _delay_ms(500); right(); //Left wheel forward, Right wheel backward _delay_ms(1000); stop(); _delay_ms(500); soft_left(); //Left wheel stationary, Right wheel forward _delay_ms(1000); stop(); _delay_ms(500); soft_right(); //Left wheel forward, Right wheel is stationary _delay_ms(1000); stop(); _delay_ms(500); soft_left_2(); //Left wheel backward, right wheel stationary _delay_ms(1000); stop(); _delay_ms(500); soft_right_2(); //Left wheel stationary, Right wheel backward _delay_ms(1000); stop(); _delay_ms(1000); } }
// MAIN FUNCTION int main() { //init_devices2(); // White Line Following while(1) { init_devices_motion(); init_devices_adc(); lcd_set_4bit(); lcd_init(); unsigned char flag = 0; unsigned char Left_white_line = 0; unsigned char Center_white_line = 0; unsigned char Right_white_line = 0; unsigned char lwl=0; unsigned char cwl=0; unsigned char rwl=0; while(1) { Left_white_line = ADC_Conversion(3); //Getting data of Left WL Sensor Center_white_line = ADC_Conversion(2); //Getting data of Center WL Sensor Right_white_line = ADC_Conversion(1); //Getting data of Right WL Sensor flag=0; print_sensor(1,1,3); //Prints value of White Line Sensor1 print_sensor(1,5,2); //Prints Value of White Line Sensor2 print_sensor(1,9,1); //Prints Value of White Line Sensor3 if(Center_white_line<0x10) { flag=1; forward(); velocity(100,100); //_delay_ms(10000); } if((Left_white_line>0x10) && (flag==0)) { //bot_charging_process(); flag=1; forward(); velocity(130,30); } if((Right_white_line>0x10) && (flag==0)) { //bot_charging_process(); flag=1; forward(); velocity(30,130); } if(Center_white_line>0x10 && Left_white_line>0x10 && Right_white_line>0x10) { forward(); velocity(0,0); } if((((Center_white_line-Right_white_line>0)&&(Center_white_line-Right_white_line<=10))||((Right_white_line-Center_white_line>0)&&(Right_white_line-Center_white_line<=10)))&& (((Center_white_line-Left_white_line>0)&&(Center_white_line-Left_white_line<=10))||((Left_white_line-Center_white_line>0)&&(Left_white_line-Center_white_line<=10)))&& (((Left_white_line-Right_white_line>0)&&(Left_white_line-Right_white_line<=10))||((Right_white_line-Left_white_line>0)&&(Right_white_line-Left_white_line<=10))) ) // recognising node position that is if the reading at all three white line sensors differ maximum by 10 then that point will be node { lwl=Left_white_line; cwl=Center_white_line; rwl=Right_white_line; stop(); _delay_ms(500); break; } } bot_charging_process(); //buzzer(); for(int t=max_angle_of_bot;t>=0;t--) { soft_left_2(); //left wheel forward leaving the right wheel at rest to get //soft rotation at the axis of right wheel _delay_ms(rot_time); stop(); _delay_ms(100); } forward(); _delay_ms(100); } }