US-100 Ultrasound sensor doesn't work


            hi

im using arduino mega 2560, , tried connect us-100 ultrasonic sensor distance measurement.

i connected shown in image below(conn.jpg).

the code used was:

const int trigger=6;
const int echo=7;
float distance;
void setup(){
serial.begin(9600);
pinmode(trigger,output);
pinmode(echo,input);
}
void loop(){
// trigger us-100 start measurement
// set trigger
digitalwrite(trigger,low);
delaymicroseconds(5);
// start measurement
digitalwrite(trigger,high);
delaymicroseconds(10);
digitalwrite(trigger,low);
// acquire , convert mtrs
distance=pulsein(echo,high);
distance=distance*0.0001657;
// send result uart
serial.println(distance);
delay(50);
}

but won't work, in output 0.00 cm shown in image sm.jpg

can tell me if i'm doing wrong(also, tried putting 2 probes between vcc , 1 of gnd pins, , resistance shown.this should mean sensor isn't broken.yes?)? first time using arduino , appreciate fix this.



Arduino Forum > Using Arduino > Sensors > US-100 Ultrasound sensor doesn't work


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code