Arduino obstacle avoidence robot? (help with code)

im kinda new to arduino and was wondering if anyone could help me with the code, I want to try and run so heres what im making the robot out of...

-adafruit trinket pro 3.3 v (im using usb to uplad code)

-6v battery

-2 continous rotation servos (9g Continuous Rotation Micro Servo)

-Mini Spy Camera with Trigger for Photo or Video (this ones optional becuase i also have a non-pro trinket 3.3v which i can seperatly connect the camera to but the camera just has 3 wires red black and white which is for the trigger wire.

  • polu carrier digital distance sensor (min 2 cm max 10 cm)

(I am planning on making the robot out of a 3d chassie)

basically what i want the code to do is when the sensor reads an abject about 8cm away it was go back just a little and the turn left or right.

one more thing i want to add is that i have seen a lot of people using ultrasonic sensors as the main sensor of their obstacle detection robot so if its easier you can write the code for an HC-SRO4 ultrasonic sensor but it would be apreciated if you used the polu carrier digitsl distance sensor 10cm.

anyways this may be a lot to ask and if it is please give me some tips on how i can make a code like this while having almost no experience with arduino coding. thanks!

(deleted)

Hi,

Some example working code for obstacle avoidance with Ultrasonic is HERE:

anyways this may be a lot to ask and if it is please give me some tips on how i can make a code like this while having almost no experience with arduino coding. thanks!

Absolutely! That is what we are here to do!

Tips:
Do not attempt a complex project all at once.
Break it down into small steps.
Make your servos work.
Make them work for forward, reverse and turns.
Read sensors.
Then try to combine them.

There are many tutorials out there for servos and sensors. Look at some of them. Try some of them.
If you run into problems, post here with your code (use code tags), a wiring diagram (pencil, paper and a camera are usually good enough), and a description of what the program actually does differs from what you expect it to do.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Please post links to all the hardware you are proposing to use, specs/data.

Thanks. Tom... :slight_smile: