problem taking delay out of ping code

Hey all, I'm trying to replace the delay in the ping sensor example code with a timer delay so that I can have other things running at the same time. I am getting hung up in my attempts and I am new to this. Here is the code I have so far

/* Ping))) Sensor
  
   This sketch reads a PING))) ultrasonic rangefinder and returns the
   distance to the closest object in range. To do this, it sends a pulse
   to the sensor to initiate a reading, then listens for a pulse 
   to return.  The length of the returning pulse is proportional to 
   the distance of the object from the sensor.
     
   The circuit:
    * +V connection of the PING))) attached to +5V
    * GND connection of the PING))) attached to ground
    * SIG connection of the PING))) attached to digital pin 7

   http://www.arduino.cc/en/Tutorial/Ping
   
   created 3 Nov 2008
   by David A. Mellis
   modified 30 Aug 2011
   by Tom Igoe

   This example code is in the public domain.

 */

// this constant won't change.  It's the pin number
// of the sensor's output:
const int pingPin = 7;

//timer
long previousepingtimer = 0;
long pingpausetwo = 2;
long pingpausefive = 5;
long pingpauselong = 100;
long initialtimer=0

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
}

void loop()
{
 unsigned long currentMillis = millis();            //start timer


  // establish variables for duration of the ping, 
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
   
  pinMode(pingPin, OUTPUT);
 if(currentMillis - previousepingtimer = initialtimer) 
 {
  digitalWrite(pingPin, LOW);
}  
   if(currentMillis - previousepingtimer = pingpausetwo) 
  {
  digitalWrite(pingPin, HIGH);
  }
   if(currentMillis - previousepingtimer - pingpausetwo = pingpausefive) 
   {
  digitalWrite(pingPin, LOW);
   

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
   }
   
  if(currentMillis - previousepingtimer - pingpausetwo - pingpausefive = pingpauselong)
  {
    previousepingtimer = currentMillis;
  }
}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

I am getting the error sketch_jun02b:28: error: expected unqualified-id before numeric constant sketch_jun02b:36: error: expected ',' or ';' before 'void' sketch_jun02b.ino: In function 'void loop()': sketch_jun02b:54: error: lvalue required as left operand of assignment sketch_jun02b:58: error: lvalue required as left operand of assignment sketch_jun02b:62: error: lvalue required as left operand of assignment sketch_jun02b:84: error: lvalue required as left operand of assignment

Any help would be greatly appreciated. Thanks

if(currentMillis - previousepingtimer = initialtimer) >>>>>>> if(currentMillis - previousepingtimer == initialtimer)

Also, don't use "==", because if you miss a tick, you've got a long wait for the next time it's true!

Ta the start of the loop function you haveunsigned long currentMillis = millis();            //start timer So every time round the loop you start again so the timer will never get anywhere.

Also, don’t use “==”, because if you miss a tick, you’ve got a long wait for the next time it’s true!

YES!
Use >= or <= instead of == if there is a possible chance you may miss a variable change from an increment or decriment etc.

I'm trying to replace the delay in the ping sensor example code with a timer delay so that I can have other things running at the same time.

There are times when not using delay is not worth the effort. This is one of them. Use NewPing, which is interrupt based, instead.

brickparatrooper: Hey all, I'm trying to replace the delay in the ping sensor example code with a timer delay so that I can have other things running at the same time. I am getting hung up in my attempts and I am new to this. Here is the code I have so far

[... snip ...]
//timer
long previousepingtimer = 0;
long pingpausetwo = 2;
long pingpausefive = 5;
long pingpauselong = 100;
long initialtimer=0

No one else caught this... You are missing a semicolon after declaring and initializing initialtimer... I didn't do a line number count, but that would be my guess for the first two error lines:

sketch_jun02b:28: error: expected unqualified-id before numeric constant sketch_jun02b:36: error: expected ',' or ';' before 'void'

The other errors may be fallout from that missing semicolon. I didn't look to see though...