How to give perfect U-turn to your robot? Straight track follower robot

This is the THIRTEENTH PROGRAM in your course of FUNDAMENTALS OF ROBOTICS. To use this program, you must use our robotics kit already supplied to you.U-turn

If you do not have this kit, then you can purchase our distance learning programme in robotics or contact us to join our regular batches of robotics.

Now read the following program carefully and work as per the given instructions, to enjoy your FIRST COURSE in robotics.

To use this program directly for your robotic kit, copy it, create new project in AVR Studio and then paste it into the coding area. Then compile it. OR ELSE, DESIGN YOUR OWN, BY REFERRING TO THIS PROGRAM.

/*
	Applicable to ATMega8/16/32/128
	*** CONNECTION DETAILS OF KIT ***
	1) The 2 motors in your kit, are connected to PB4-PB1, as follows:
	   Left motor:  PB4 -> (+) and PB3 -> (-)
	   Right motor: PB1 -> (+) and PB1 -> (-)
	2) Connect the 5 sensors array to PC4 & PC0 in your kit.
	   Connect LEFTMOST SENSOR to PC4 and RIGHTMOST SENSOR to PC0
*/
#define F_CPU 12000000UL 
#include <avr/io.h>
#include <util/delay.h>
int main() 
  { 
	DDRB=0b00011110; 
	DDRC=0b0000000;  
	int s=0; 
  
while(1) 
  { 
s=PINC&0b0011111; // masking the sensor status
if(s==0b0000000)
  {
  PORTB=0b00000000; // STOP
  }

if(s==0b0011011) 
  {
  PORTB=0b00010010; // GO FORWARD 
  }

if((s==0b0000111)||(s==0b0001111))
  {
  PORTB=0b00001010; // POWER LEFT
  }
 
if((s==0b0010011)||(s==0b0010111))
  {
  PORTB=0b00000010; // SOFT LEFT
  }

if((s==0b0011100)||(s==0b0011110))
  {
  PORTB=0b00010100; // POWER RIGHT
  }

if((s==0b0011001)||(s==0b0011101))
  {
  PORTB=0b00010000; // SOFT RIGHT
  }
		if(s==0b0011111) 
		{
			PORTB=0b00010100;
			_delay_ms(300);
					if(s==0b0011011)
					PORTB=0b00010010;
					else
					continue;	
		} 
		} // while closed
	} // main closed

How to use and run this program on your kit?

  1. First you will require the 5 sensor array card, which is readily available at us. You can purchase it by contacting us at: http://www.vsagar.org/contact-us.
  2. Now connect the card to PC4 & PC0 in your kit. Connect LEFTMOST SENSOR to PC4 and RIGHTMOST SENSOR to PC0.
  3. Now keep a black paper or sheet below all the sensors. Switch on the robot battery supply and adjust the sensitivity of all the sensors such that their indicator LEDs will just turn OFF.
  4. Once this adjustment is done, burn the code given above into your robot microcontroller.
  5. Now fix a long black track (approx. 1m length) on smooth floor or plywood using black tape.
  6. Then keep the robot on the track such that its center IR sensor will be exactly on black track.
  7. Switch on the battery supply of the robot. Your robot will start following the track up to the end.
  8. When it reaches at the end of the track, all the sensor indicator LEDs will glow and the robot will take U-turn, until its middle sensor is again on black track.
  9. Again it will follow the black track to the other end and will take U-turn.
  10. In this way, it will continue traversing the black track to-and-fro.
  11. Is it working? Nice!
  12. Now don’t forget to give your valuable feedback to us on our website: http://www.vsagar.org/contact-us.
About the author: Admin of Vidyasagar Academy to post all types of educational material required for our students. This material is equally helpful to our online students.

Comments on this entry are closed.