Slowly decreasing the motors.

We are working on our single fly wheel with the flywheel vertical to where the ball will be coming from. We are using buttons 6U to start the flywheel to full speed (127). Our motors overheat at times and we would like to know in the programming how we could program it to where the motors speed gradually decreases from 127 to 0 instead of quickly trying to stop when we release the button.

Many ways to do it, here is one example.


for(int x = 70; x>0; x--)
{
motor[leftflywheel1] = x;
motor[leftflywheel2] = x;
motor[rightflywheel1] = x;
motor[rightflywheel2] = x;
delay(100);
}

This code will set the flywheel motors to 70 then decrease the motor power by one every tenth of a second. You should be able to tweak/change things to suit what you need.