int main(void) { init_devices(); while(1) { forward_mm(100); //Moves robot forward 100mm stop(); _delay_ms(500); back_mm(100); //Moves robot backward 100mm stop(); _delay_ms(500); left_degrees(90); //Rotate robot left by 90 degrees stop(); _delay_ms(500); right_degrees(90); //Rotate robot right by 90 degrees stop(); _delay_ms(500); soft_left_degrees(90); //Rotate (soft turn) by 90 degrees stop(); _delay_ms(500); soft_right_degrees(90); //Rotate (soft turn) by 90 degrees stop(); _delay_ms(500); soft_left_2_degrees(90); //Rotate (soft turn) by 90 degrees stop(); _delay_ms(500); soft_right_2_degrees(90); //Rotate (soft turn) by 90 degrees stop(); _delay_ms(500); } }
int main(void) { data = UDR0; //making copy of data from UDR0 in 'data' variable UDR0 = data; //echo data back to PC init_devices(); velocity (246, 250); //Set robot velocity here. Smaller the value lesser will be the velocity //Try different valuse between 0 to 255 while(1) { if(data == 0x38) //ASCII value of 8 { forward_mm(90); //Moves robot forward 100mm stop(); _delay_ms(700); } if(data == 0x32) //ASCII value of 2 { back_mm(90); //Moves robot backward 100mm stop(); _delay_ms(700); } if(data == 0x34) //ASCII value of 4 { left_degrees(90); //Rotate robot left by 90 degrees stop(); _delay_ms(700); } if(data == 0x36) //ASCII value of 6 { right_degrees(90); //Rotate robot right by 90 degrees stop(); _delay_ms(700); } if(data == 0x67) //ASCII value of g { soft_left_degrees(90); //Rotate robot left by 90 degrees stop(); _delay_ms(500); } if(data == 0x68) //ASCII value of h { soft_right_degrees(90); //Rotate robot right by 90 degrees stop(); _delay_ms(500); } if(data == 0x69) //ASCII value of i { left_degrees(180); //Rotate robot left by 90 degrees stop(); _delay_ms(500); } if(data == 0x70) //ASCII value of j { right_degrees(180); //Rotate robot right by 90 degrees stop(); _delay_ms(500); } if(data == 0x35) //ASCII value of 5 { stop(); _delay_ms(500);//stop } if(data == 0x37) //ASCII value of 7 { buzzer_on(); } if(data == 0x39) //ASCII value of 9 { buzzer_off(); } if(data == 0x61) //ASCII value of a { redled_on(); } if(data == 0x62) //ASCII value of b { redled_off(); } if(data == 0x63) //ASCII value of c { blueled_on(); } if(data == 0x64) //ASCII value of d { blueled_off(); } if(data == 0x65) //ASCII value of e { greenled_on(); } if(data == 0x66) //ASCII value of f { greenled_off(); } } }