making my piezobuzzer and vibrator run simultaneously with obstacle detection

LOGIC:
obstacle detection thru HC-sr04 ultrasonic sensor.
if obstacle detcted in a given range, then my vibrator and buzzer tone should be on as follows:
RANGE: vibrator buzzer tone
300-400cm slow off
200-300 cm moderate on(with less volume)
100-200 cm high on(more volume)

all the components are working fine.
enclosing sensor characteristics and my program.
P.S: do i hv to include ultrasonic library for this sensor…as i m getting the results without it too.tell me how to include and use a library in your program.
SENSOR:http://iteadstudio.com/produce/cheap-cheap-ultrasonic-ranging-modulehc-sr04/
vibrator-2.2 volts


program.txt (1.12 KB)

When should our assignment be ready by?

in week's time

duration = pulseIn(echoPin, HIGH);

Remind me: what type does pulseIn return?

pulseIn returns the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long)

Very good.
So why try to squeeze it into an int?

then wat datatype should i use?as i am using this Ton(time) to be converted into distance

also i get a bizzare output of 14 or 16 cm sometimes with this hc-sr04 sensor when there's no obstacle infront of it. ..don't know why. In that case i want to display out of range message in the serial monitor and generate a buzzer of specific tone.is it possible

then wat datatype should i use?

It is customary to use the same data type as the function returns.

cn u guide me thru other doubts posted above ?