This is a small sample of how you could use it.
And this is the code done in the arduino ide :
#define echo 8 #define trig 7 long duration,distance; void setup() { Serial.begin(9600); pinMode(echo,INPUT); pinMode(trig,OUTPUT); pinMode(5,OUTPUT); } void loop() { digitalWrite(trig,LOW); delayMicroseconds(2); digitalWrite(trig,HIGH); delayMicroseconds(10); digitalWrite(trig,LOW); duration=pulseIn(echo,HIGH); distance=(duration/(2*29)); if(distance>=500 || distance<=0){ Serial.println("____"); } else{ Serial.print(distance); Serial.println("cm."); digitalWrite(5,LOW); } if(distance<=45 && distance>=1){// distance in which the bracelet vibrates, you can edit according to your need digitalWrite(5,HIGH); Serial.println("Alarm!!!"); } delay(400); }