I have a working sketch for a trashcan using a one servo and a distance sensor so when my hand comes close the the sensor the servo activates but i would like to slowdown the movement of the servo so the lid of the trashcan doesn't go flying i have tried researching but i don't really understand it. Here is the sketch
I have a library for this named ServoSweep. Maybe that you find it usefull, maybe not who knows. You can find it in this git folder. You would need both the .cpp and .h file.
All you need to do is construct a servo sweep object with following parameters ServoSweep::ServoSweep( uint8_t _servoPin, uint8_t _min, uint8_t _max, uint8_t _turnOff, uint8_t _speed )
example: ServoSweep myMotor( pin, 30, 120, 1, 20) ;
Speed is the time in milliseconds that a motor shift one degree, so smaller speed is.. higher speed.. because logic
Min and max are the positions in degrees
Optionally you can let the motor to turn off when it reaches position. This can be usefull sometimes.
From void setup() you call myMotor.begin() ; to initialize the thing and from within loop() you have to call myMotor.sweep() ; continously.
With myMotor.setState( 0 ) ; // or 1 you can set the motor to either min or max positions.