build a robot

Hi everyone, I have a question. I want to make an arduino robot that will drive forward until it detects an object 1 inch in front of it than turn right/left and move forward again until it detects another object 1 inch in front of it. I also want to have to robot drive forward towards a red colored object and stop when its about 2 inches away than move the claw to pick up the object. If you can help me with some sample code or tips that would be great! Thanks!

Moved your topic to it's current location / section as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Imagine that we know nothing about your robot or its capabilities.

Now, what were your questions?

Start by working your way through the material in this great site.

All you need is a motor driver(L298N or L293D) and a servo motor along with an HC SR04 ultrasonic sensor.
You can install the ultrasonic library, which you can find here:

https://github.com/ErickSimoes/Ultrasonic

This is a great link, explaining the library. Using the library, you can find out how to measure distance from an object.
You can also include the servo library <servo.h> to work with the servo motor.
Then, to move forward, you basically digitalWrite(pin, HIGH) for both wheels(or for how many wheels you have). To move backwards too, it is the same code, but on a different pin.(Each motor has two wires. In BO motors, one of them is for moving forward while the other is fro moving backward-you have to figure it out via trial and error.)
Other than that, just use code from libraries, and the logic you already gave.

MukeshArvindh:
All you need is a motor driver(L298N or L293D)

Or to put it another way,

All you need is a motor driver(anything other than a L298N or L293D)