Skip to content

Commit d8ede12

Browse files
authoredOct 14, 2020
Merge pull request #1171 from viren-vii/patch-2
Create moistureSensor
2 parents 456e9ae + 6adeeba commit d8ede12

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
 

‎Arduino_Code/moistureSensor

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <Servo.h>
2+
Servo servodry; // create servo object to control a servo for dry waste container
3+
Servo servowet; // create servo object to control a servo for wet waste container
4+
Servo servomet; // create servo object to control a servo for metal waste container
5+
int val;
6+
int sensor_pin = ; //pin declaration
7+
8+
void setup() {
9+
pinMode(led_pin, OUTPUT);
10+
pinMode(sensor_pin, INPUT);
11+
servodry.attach(*pin*); // attaches the servodry on pin *pin* to the servo object
12+
servowet.attach(*pin*); // attaches the servowet on pin *pin* to the servo object
13+
servomet.attach(*pin*); // attaches the servomet on pin *pin* to the servo object
14+
}
15+
16+
void loop() {
17+
18+
val = map(val, 0, 1023, 0, 180);
19+
if(digitalRead(sensor_pin) == HIGH){
20+
for(val=0; val<=90; val++)//this is to open lid of container of wet waste (i dont know your hardware settings so change according to it) val is in terms of angle
21+
{
22+
servowet.write(val);// sets the servo position according to the scaled value
23+
}
24+
delay(3000);
25+
for( ;val>=0;val--) //this is to close lid of container of wet waste (i dont know your hardware settings so change according to it) val is in terms of angle
26+
{
27+
servowet.write(val);// sets the servo position according to the scaled value
28+
}
29+
}
30+
else {
31+
for(val=0; val<=90; val++) //this is to open lid of container of dry waste (i dont know your hardware settings so change according to it) val is in terms of angle
32+
{
33+
servodry.write(val);// sets the servo position according to the scaled value
34+
}
35+
delay(3000);
36+
for( ;val>=0;val--) //this is to close lid of container of dry waste (i dont know your hardware settings so change according to it) val is in terms of angle
37+
{
38+
servowet.write(val);// sets the servo position according to the scaled value
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.