duration=pulseIn(echoPinSensor,HIGH);//pulseIn funtion will return the time on how much the configured pin remain the level HIGH or LOW; in this case it will return how much time echoPinSensor stay HIGH
distance=(duration/2)/29.1;// first we have to divide the duration by two
returndistance;
}
intinfrarot_sensor(){
intzustand=0;
intstatus_sensor=digitalRead(IR_sensor);
if(status_sensor==HIGH){
zustand=0;
}
else{
zustand=1;
}
returnzustand;
}
voidwassersensor(){
// Wassersensor
intvalue=analogRead(waterPin);
if(value>350){
PORTD=PORTD|(1<<2);
delay(1000);
PORTD=PORTD&~(1<<2);
delay(1000);
}
}
voidnotruf(){
intstatus_button=digitalRead(button);
if(status_button==LOW){
Phone.call("004917675867969");
}
else{
PORTD=PORTD&~(1<<4);
PORTD=PORTD&~(1<<5);
PORTD=PORTD&~(1<<2);
}
}
inti=0;
voidgiroscope(){
/* Always get the values of the accelerometer in the 3 dimensions (X, Y and Z). */
floatx,y,z;
intmagnitudeThreshold=25;
x=AccelerometerSensor.getX();
y=AccelerometerSensor.getY();
z=AccelerometerSensor.getZ();
/* Check the motion of the smartphone, if it exceeded a limit, turn the LED on. */
/* We do that by calcuating the magnitude of the 3D vectors. */
if(sqrt((x*x)+(y*y)+(z*z))>magnitudeThreshold)
{
Phone.call("004917675867969");
floatlat=GPS.getLatitude();
floatlon=GPS.getLongitude();
i=i+1;
Stringsendlat="Latitude: "+String(lat);
Stringsendlon="Longitude: "+String(lon);
Stringmsg1="Hello fam I need help my GPS Coordinates are:\n";