How to make object detection sensor?

hi,

    I have succesfully made my first robot and now want to add an object detection and line following sensor. Which is the best sensor  for object detection and line following .Or somthing that can be home made.

There is no “best” sensor.

Ultrasonic sensors can be found for less than $3 USD on ebay. Ultrasonic sensors in general work fine until you get something soft and/or fuzzy; sound bounces off of hard, solid objects. IR is useful for object detection and line following, depending on orientation. IR has a weakness and that is dark colors, especially black. You could make touch sensors or bump switches from bits of wire. Line following is probably best done with IR sensors, but, you can use LEDs and any number of receptive sensors to follow a line.

there are many possibilities to detect an object

There are many many possibilities to detect an object. Either you make a sensor that detects an object when it has physical contact or visual contact or capacitive contact.

Physical contact can be detected with a bump sensor. This bump sensor is nothing more than a on/off switch. It goes on when the robot bumped into an object.

Visual contact can be detected with a reflection-measurement. You can reflect light or ultrasound. Home made sensors often use light like the FritsLDR that uses visible light or the IR object detection sensor that uses non-visible light.