forked from VAR-solutions/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoistureSensor
More file actions
41 lines (38 loc) · 1.79 KB
/
moistureSensor
File metadata and controls
41 lines (38 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <Servo.h>
Servo servodry; // create servo object to control a servo for dry waste container
Servo servowet; // create servo object to control a servo for wet waste container
Servo servomet; // create servo object to control a servo for metal waste container
int val;
int sensor_pin = ; //pin declaration
void setup() {
pinMode(led_pin, OUTPUT);
pinMode(sensor_pin, INPUT);
servodry.attach(*pin*); // attaches the servodry on pin *pin* to the servo object
servowet.attach(*pin*); // attaches the servowet on pin *pin* to the servo object
servomet.attach(*pin*); // attaches the servomet on pin *pin* to the servo object
}
void loop() {
val = map(val, 0, 1023, 0, 180);
if(digitalRead(sensor_pin) == HIGH){
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
{
servowet.write(val);// sets the servo position according to the scaled value
}
delay(3000);
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
{
servowet.write(val);// sets the servo position according to the scaled value
}
}
else {
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
{
servodry.write(val);// sets the servo position according to the scaled value
}
delay(3000);
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
{
servowet.write(val);// sets the servo position according to the scaled value
}
}
}