RP5 Rover with HC-SR04

Drive a 4-wire bipolar stepper motor or a pair of DC motors from your Arduino. [Product page]
Post Reply
CAMS2908
Posts: 9
Joined: Thu Jan 01, 2015 8:39 pm

RP5 Rover with HC-SR04

Post by CAMS2908 » Thu Jan 01, 2015 8:52 pm

Hi

I am in the process of building a tankbot using an RP5 chassis unit with ultrasonic distance component attached to servo in sweep. I seem to be able to get the tank moving on its own. However, can not seem to get other individual sketches to meld with it. I have found the sketch for this moment but can not seem to find anywhere the sketch that uses all freetronics (eleven, hbridge) components, a servo and HC-SR04 ultrasonic component attached to an RP5 chassis Could I please have some help with the construction of these sketches as at the moment it is doing my head in! :evil:

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: RP5 Rover with HC-SR04

Post by andrew » Thu Jan 01, 2015 10:17 pm

A common beginner's trap is to try an mash up code for different things into one sketch, this usually doesn't end well :)

First learn how to write sketches to control individual parts in your project so you have a solid understanding of their operation.
Then break down your problem/task into individual steps and create an order of doing things and what you want to happen if certain events occur (an "algorithm").

E.g.
turn motors on forward
loop
move distance sensor with servo one degree
check distance sensor value - if a certain value stop motors/turn/etc.
end loop

etc.
Then you can translate this into code with success.

Also I cannot recommend enough a book we have available "Arduino Workshop" which in fact has a project incredibly similar to what you're doing:
http://www.freetronics.com.au/collectio ... o-workshop

CAMS2908
Posts: 9
Joined: Thu Jan 01, 2015 8:39 pm

Re: RP5 Rover with HC-SR04

Post by CAMS2908 » Thu Jan 01, 2015 10:54 pm

Thanks. I have tried the book that you listed below. Which is where I have been working from however, with it using different motor shield and different ultrasonic sensor has confused the hell out of me.....
Also I cannot recommend enough a book we have available "Arduino Workshop" which in fact has a project incredibly similar to what you're doing:
http://www.freetronics.com.au/collectio ... o-workshop

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: RP5 Rover with HC-SR04

Post by andrew » Fri Jan 02, 2015 7:43 am

Ok, good choice.

Don't panic, just look at the larger question as a bunch of small ones, such as the HBRIDGE shield.

First - check out out HBRIDGE guide, scroll down to "Controlling A 2-Wire DC Motor" and and try the example, so you know how the shield works:
http://www.freetronics.com.au/pages/hbr ... tart-guide

With your RP5 tank base (assuming you're using the 6 x AA cells to power it) connect the power leads from the AA cell holder to the motor power terminal header on the HBRIDGE shield, and also fit the "bridge Vin to motor power" jumper.

The last sketch demonstrates how to move the motors forward, reverse and adjust speed.

Then go over to project 40 in the book, as this is the foundation of the tank project you're working on. With the knowledge from the last sketch in the HBRIDGE tutorial page you can replicate project 40, then carry on with the tank project.

Post Reply