i am a noob

ok i have written a code so that my robot can preform a certain objective. that object is move forward/ turn when needed........ but when one of two of my ping sensor senses an object the robot is to pick up the object and place the object in another location how ever for some reason i cant get the bot to move at all...... can some one please go thur my code real fast and let me know where my problem is........ thanks in advance for all help recieved

#include <Servo.h>

Servo servoHand;          
Servo servoWrist;         




int ultraSoundSignal1 = 7; 
int ultraSoundSignal2 = 4;

int val1 = 0;
int val2 = 0;
int ultrasoundValue1 = 0;
int ultrasoundValue2 = 0;
int timecount1 = 0;
int timecount2 = 0; // Echo counter
int duration1 = 0;
int duration2 = 0;



void setup() {
  servoHand.attach(10);  
  servoWrist.attach(5);   


Serial.begin(9600);
//setup channel A
pinMode(12, OUTPUT); 
pinMode(9, OUTPUT); 
//setup channel B
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
//setup arm








}
void upandopen()
{
  servoWrist.write(130);

  servoHand.write(90);

  
}


void upandclosed() 
{
  servoWrist.write(130);
  
  servoHand.write(55);

 
}


void loweredandopen() 
{
  servoWrist.write(0);

  servoHand.write(90);


}

void loweredandclosed()
{
  servoWrist.write(0);

  servoHand.write(55);
 

}

void forward()
{
digitalWrite(12, HIGH);
digitalWrite(9, LOW);
analogWrite(3, 255);
digitalWrite(13, LOW);
digitalWrite(8, LOW);
analogWrite(11, 255);
}

void turn_left()
{

  
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
delay(300);

digitalWrite(12, HIGH);
digitalWrite(9, LOW);
analogWrite(3,65);
digitalWrite(13, HIGH);
digitalWrite(8, LOW);
digitalWrite(11, 65);
delay(300);
}

void turn_right()
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
delay(300);

digitalWrite(12, LOW);
digitalWrite(9, LOW);
analogWrite(3,65);
digitalWrite(13, LOW);
digitalWrite(8, LOW);
digitalWrite(11, 65);
delay(300);
}

void dontmove()
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
}


void reverse()
{
digitalWrite(12, LOW);
digitalWrite(9, LOW);
analogWrite(3, 255);
digitalWrite(13, HIGH);
digitalWrite(8, LOW);
analogWrite(11, 255);
}

void u_turn()
{

  
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
delay(300);

digitalWrite(12, HIGH);
digitalWrite(9, LOW);
analogWrite(3,125);
digitalWrite(13, HIGH);
digitalWrite(8, LOW);
digitalWrite(11, 125);
delay(300);
}












void loop() {




pinMode(ultraSoundSignal1, OUTPUT); 



digitalWrite(ultraSoundSignal1, LOW); 
delayMicroseconds(2); 
digitalWrite(ultraSoundSignal1, HIGH); 
delayMicroseconds(5); 
digitalWrite(ultraSoundSignal1, LOW); 



pinMode(ultraSoundSignal1, INPUT); 
duration1 = pulseIn(ultraSoundSignal1, HIGH);
Serial.println(duration1/74/2);

delay(100);

}

{
{
timecount2 = 0;
val2 = 0;
pinMode(ultraSoundSignal2, OUTPUT); 

digitalWrite(ultraSoundSignal2, LOW); 
delayMicroseconds(2); 
digitalWrite(ultraSoundSignal2, HIGH); 
delayMicroseconds(5); 
digitalWrite(ultraSoundSignal2, LOW);



pinMode(ultraSoundSignal2, INPUT);
duration2 = pulseIn(ultraSoundSignal2, HIGH);
Serial.println(duration2/74/2);

delay(100);
{
ultrasoundValue1 = duration1/74/2;
ultrasoundValue2 = duration2/74/2; 
}

 





upandopen();
while(servoHand.read() == 90 && servoWrist.read() == 130);
{

if (ultrasoundValue2 > 2.00 && ultrasoundValue1 > 16.00 )

{
upandopen();
forward();
}





else if( 16.00 < ultrasoundValue1 && ultrasoundValue2 == 2.00)
{
dontmove();
loweredandclosed();
upandclosed();
u_turn();
}

else if (( 16.00 <= ultrasoundValue1 && ultrasoundValue1 > 32.00) && ( ultrasoundValue2 == 2.00))
{
dontmove();
loweredandclosed();
upandclosed();
u_turn();
}



else if (ultrasoundValue1<= 16.00  && ultrasoundValue2 <= 16.00)
{
dontmove();
turn_left();
forward();
}

else
{
dontmove();
reverse();
}
}

while( servoWrist.read() == 130 && servoHand.read() == 55)
{
if(ultrasoundValue1> 50.00)
{
forward();
}

else if( ultrasoundValue1 < 50.00 && ultrasoundValue1 < 44.00)
{
dontmove();
turn_right();
forward();
}

else if ( ultrasoundValue1 >= 32.00 && ultrasoundValue1 > 10.00)
{
forward();
}

else if ( ultrasoundValue1 < 10.00 && ultrasoundValue2 == 2.00)
{
dontmove();
loweredandopen();
reverse();
delay(100);
upandopen();
u_turn();
}}}}}

ok i found one problem i was having...... that is that i had the ultrasoundValue= 74/...... bloacked out..... once put back into play i now have another issue of.... and that is that the ping sensor will only work for a 4 seconds then stop working ...... any one willing to help with a reason for that ...... the only thing i can think of is that my code is too long which i dont think thats the issue but if that is possible can some one lead me on how to fix that issue

ok i blocked out the while statements and now the code seems to be runnning some what fine
but i dont know how to go about fixing it any one willing to help

Read this before posting a programming question

Please edit your original post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

You might also want to consider using the auto-format tool.

Also, as a courtesy, please remove all commented-out code before posting.

sry guys as i stated in the topic i am a noob ......... but i have fixed it.............bump tty........ thanks in advance for any help

as i stated in the topic i am a noob

...which is why the sticky is there at the top of this section, with its title in bold

I'm waiting to see what PaulS thinks of your code.

Unless you've just arrived from Mars, you should know that before you post on a forum, you should read the "sticky".

Amongst other things it suggest you make meaningful thread titles. "I am a noob" is not helpful.

I'm waiting to see what PaulS thinks of your code.

Not

a
whole

lot.

And we should add to that sticky - read the documentation! From the servo lib doc's in the reference

On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

Mark