Need a little help with a bot.

Right here goes,

I have been playing with arduino for a little while now gathering parts and bits of knowlege from everyone on the forum, Thanks to all that post and to you coders who can make sense of the mess that us noobs spew out.

On to the real point…

I am using,
DFRduino mega 1280
DFRduino motor drive
Unknown brand Ultrasonic Sensor HC-SRo4
Micro servo
and i am using Tracks and chassis from an ebay £10 transit damaged RC Tank

I have had everything working, Tracks, Mega and Motor drive with buttons, pots and on “auto” with bump sensors no problems.
I have also had the Ultrasonic Sensor working with the LCD to output the distance in CM.

Heres my first post of code:

include “Ultrasonic.h”

#include <Servo.h>

Ultrasonic ultrasonic (8,9);
Servo scanservo;

const int RTMPin = 5 ;
const int RTRPin = 4 ;
const int LTMPin = 6 ;
const int LTRPin = 7 ;

const int ledPin = 13;

void setup() {

pinMode (RTMPin, OUTPUT);
pinMode (RTRPin, OUTPUT);
pinMode (LTMPin, OUTPUT);
pinMode (LTRPin, OUTPUT);

pinMode (ledPin, OUTPUT);

scanservo.attach(9);
analogWrite(RTMPin, 50);
analogWrite(LTMPin, 50);

}

void loop()
{

scanservo.write(120);
delay(500);

if (ultrasonic.Ranging(CM)<15){
digitalWrite(RTRPin, HIGH);
delay(500);
digitalWrite(RTRPin, LOW);
}
delay(500);
scanservo.write(90);
delay(500);
scanservo.write(60);
delay(500);

if (ultrasonic.Ranging(CM)<15){
digitalWrite(LTRPin, HIGH);
delay(500);
digitalWrite(LTRPin, LOW);
}

delay(500);
scanservo.write(90);
delay(500);
}


I have tried the analogWrite in the loop tried it digital made the delays longer, I had it previously switching Pin 13 when i was testing the Servo and Sensor, What do you think??

Do not cross post.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293408718/0#0