0% found this document useful (0 votes)
105 views2 pages

Dry Wet Code

Uploaded by

negia8141
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views2 pages

Dry Wet Code

Uploaded by

negia8141
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Nakul Sahu Art

#include <Servo.h>
Servo servo1;
const int trigPin = 12;
const int echoPin = 11;
long duration;
int distance=0;
int potPin = A0;
int soil=0;
int fsoil;
int maxDryValue=1; //this value decides how much humidity require to treat waste as
wet object
int Ultra_Distance=15; //set Distance between Ultrasonic and moisture(soil) sensor
in cm
void setup()
{
[Link](9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
[Link](8);
[Link]("Soil Sensor Ultrasonic Servo");
}
void loop()
{
int soil=0;
for(int i=0;i<2;i++)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(7);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
delayMicroseconds(10);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2+distance;
delay(10);

}
distance=distance/2;

if (distance <Ultra_Distance && distance>1)


{
delay(1000);
for(int i=0;i<3;i++)
{
soil = analogRead(potPin) ;
soil = constrain(soil, 485, 1023);
fsoil = (map(soil, 485, 1023, 100, 0))+fsoil;
delay(75);
}
fsoil=fsoil/3;

[Link]("Humidity: ");
[Link](fsoil);
[Link]("%"); [Link](" Distance:
");[Link](distance);[Link](" cm");
if(fsoil>maxDryValue)
{delay(1000);
[Link](" ==>WET Waste ");
[Link](170);
delay(3000);}
else{ delay(1000);
[Link](" ==>Dry Waste ");
[Link](10);
delay(3000);}

[Link](90);}
distance=0;
fsoil=0;delay(1000);
}

Common questions

Powered by AI

The system assumes an indoor environment where distance and soil moisture readings are critical for classifying waste. The maxDryValue indicates it is tuned for specific moisture ranges, implying the waste must be within the Ultra_Distance range (less than 15 cm) for accurate measurement. This environment likely involves small, controlled waste processing settings where waste is manually or automatically brought close to sensors for classification .

The averaging logic in distance measurement involves taking two readings separated by short delays, summing them, and dividing by two. This approach reduces the impact of transient anomalies or noise on individual measurements, leading to more accurate and stable distance readings. Consistent distance measurements are crucial for ensuring that the soil sensor is within the effective range for accurate moisture detection .

The ultrasonic sensor uses pin 12 as the trigPin for sending pulses and pin 11 as the echoPin for receiving pulses. The servo motor is attached to pin 8. The interaction involves the ultrasonic sensor measuring the distance to ensure the object is in range and the servo motor responding based on soil moisture readings to classify the waste .

The ultrasonic sensor determines distance by sending a high pulse using the trigPin and receiving the echo on the echoPin. The duration of the pulse is measured, and this value is used in the formula distance = duration * 0.034 / 2 to calculate the distance in centimeters. This works because the speed of sound is approximately 0.034 cm/µs, and the division by 2 accounts for the round trip of the sound waves .

The algorithm takes three soil moisture readings by using analogRead(potPin), constrains the values, and maps them to a percentage scale from 100 to 0. These values are summed up and averaged over the three readings by dividing the sum by three. This averaging is necessary to smooth out fluctuations and provide a more stable measurement of soil moisture .

The servo motor acts to categorize the waste as either wet or dry. It turns to 170 degrees if the detected soil moisture is above the threshold (indicating wet waste) and turns to 10 degrees if below the threshold (indicating dry waste). These positions are controlled by the statement servo1.write(), which specifies the angle to rotate the servo motor based on the condition check of the soil moisture .

Improvements could include implementing adaptive thresholds that adjust based on environmental conditions or waste type analytics to improve accuracy. upgrading to digital moisture sensors could increase precision. Adding network connectivity, such as Wi-Fi or Bluetooth, would allow integration with larger waste management systems for data collection and process optimization. Moreover, reducing or optimizing delays and expanding the sensor's range could enhance flexibility and scalability .

The system differentiates wet and dry waste by comparing the averaged soil humidity reading against a predefined threshold (maxDryValue). If the humidity reading (fsoil) is greater than this threshold, it classifies the waste as wet and turns the servo to 170 degrees. Otherwise, it classifies it as dry and sets the servo to 10 degrees. This decision process involves both the ultrasonic and moisture sensors to ensure proper classification .

Potential limitations include reliance on a fixed threshold for soil moisture, which may not adapt to different waste types or humidity levels. The requirement for objects to be within 15 cm limits scalability and throughput, making it unsuitable for large-scale operations. Delays in the system impact responsiveness and may not handle continuous flow setups efficiently. Environmental factors like temperature or sensor malfunctions could further affect reliability and classification accuracy .

The delay functions are used to stabilize readings and ensure proper timing between actions. Short delays occur after setting the trigPin to ensure reliable ultrasound transmission. Delays between moisture readings provide time for accurate sampling, while delays after determining waste type (wet or dry) prevent abrupt servo movements and allow time for mechanical completion of actions. They ensure stability but can slow down response time in high-speed applications .

You might also like