Issue with ping sensor and motor shield

When I put my hand 12 inches from the sensor, the motor goes backwards. Any other distance has no effect. Any ideas?

Boards:
HC-SR04 Ping Sensor
http://www.sainsmart.com/sainsmart-l293d-motor-drive-shield-for-arduino-duemilanove-mega-uno-r3-avr-atmel.html?___store=en&___store=en

#include <AFMotor.h>

#define pingPin A5
#define echoPin A3

AF_DCMotor motor(4, MOTOR12_64KHZ); // create motor #4, 64KHz pwm

void setup() {

  Serial.begin(9600);
  motor.setSpeed(200);     // set the speed to 200/255
}

void loop() {
  long duration, inches;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);

  inches = microsecondsToInches(duration);
  
  Serial.print(inches);
  Serial.print("in, ");
  Serial.println();
  
if (inches < 12){
    
  motor.run(BACKWARD);     // Reverse for 2 seconds
  delay(2000);

  }
}

long microsecondsToInches(long microseconds)
{
  return microseconds / 74 / 2;
}

The code should be in code tags as explained...

Anyway you simply set the motor running backwards the first time you see
an echo from 12 in or less, and leave it running that way. You don't cancel
the motion after the delay.

Your microseconds variable doesn't need to be long, int will be plenty (in fact
unsigned int is applicable for a value that cannot be negative).

Thank you for the reply. And sorry about how my code was posted. I will be sure to post properly in the future.

So it should look like this?

if (inches < 12){
    
  motor.run(BACKWARD);     // reverse motor

  }
}

long microsecondsToInches(int microseconds)
{
  return microseconds / 74 / 2;
}