Here is the problem :
C:\Users\younes\Desktop\ALLTogether\ALLTogether.ino: In function 'long int vibration()':
C:\Users\younes\Desktop\ALLTogether\ALLTogether.ino:153:5: warning: return-statement with no value, in function returning 'long int' [-fpermissive]
return;
And the Program
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define ventilo 4
int maxHum = 85;
int maxTemp = 30;
DHT dht(DHTPIN, DHTTYPE);
int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A0;
// Your threshold value
int sensorThres = 50;
#define LED_PIN 5
#define POWER_PIN 7
#define SIGNAL_PIN A5
#define THRESHOLD 300
int value = 0; // variable to store the sensor value
int vs=A4;// vibration sensor
int led=13;
int BUZZER=10;
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT); // configure D2 pin as an OUTPUT
pinMode(POWER_PIN, OUTPUT); // configure D7 pin as an OUTPUT
digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
digitalWrite(LED_PIN, LOW); // turn LED OFF
pinMode(led,OUTPUT);
pinMode(BUZZER,OUTPUT);
pinMode(vs,INPUT);
Serial.begin(9600);
{Serial.begin(9600);
pinMode(ventilo, OUTPUT);
dht.begin();
}
{Serial.begin(9600);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(ventilo, OUTPUT);
pinMode(smokeA0, INPUT);
}
}
void loop() {
digitalWrite(POWER_PIN, HIGH); // turn the sensor ON
delay(10); // wait 10 milliseconds
value = analogRead(SIGNAL_PIN); // read the analog value from sensor
digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
if (value > THRESHOLD) {
Serial.print("The water is detected");
digitalWrite(LED_PIN, HIGH);// turn LED ON
} else {
digitalWrite(LED_PIN, LOW); // turn LED OFF
}
long measurement=vibration();
delay(200);
Serial.println(measurement);
if(measurement>5000){
digitalWrite(led,HIGH);
digitalWrite(BUZZER,HIGH);
}
else{
digitalWrite(led,LOW);
digitalWrite(BUZZER,LOW);
}
}
long vibration(){
long measurement=pulseIn(vs,HIGH); //wait for the pin to get HIGH and returns measurement
return measurement;
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
{
int analogSensor = analogRead(smokeA0);
Serial.print("Pin A0: ");
Serial.println(analogSensor);
//Cheks if it has reached the threshold value
digitalWrite(buzzer, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(ventilo, LOW);
digitalWrite(redLed, LOW);
if(analogSensor > sensorThres)
{digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
digitalWrite(ventilo, HIGH);
digitalWrite(buzzer, HIGH);
}else if(h > maxHum || t > maxTemp)
{
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(ventilo, HIGH);
digitalWrite(buzzer, LOW);
}
}delay(100);
}