// sink splash riser
// vgmlr
#include "VarSpeedServo.h"
VarSpeedServo lservo;
VarSpeedServo rservo;
const int left = 5;
const int right = 6;
const int sensor = A0;
const int lup = 8;
const int ldown = 82;
const int rup = 7;
const int rdown = 77;
const int sup = 10;
int water;
int more;
void setup() {
lservo.attach(left);
lservo.write(ldown,150,true);
lservo.detach();
rservo.attach(right);
rservo.write(rdown,150,true);
rservo.detach();
}
void loop() {
more = 1;
water = analogRead(sensor);
if (water >= sup) {
lservo.attach(left);
rservo.attach(right);
delay(1);
lservo.write(lup,20,false);
rservo.write(rup,200,true);
while (more > 0) {
more = 0;
for (int x = 0; x < 100; x++) {
water = analogRead(sensor);
more = more + water;
}
more = more / 100;
}
lservo.write(ldown,100,false);
rservo.write(rdown,100,true);
delay(10);
lservo.detach();
rservo.detach();
}
}