 # DC-Motor, Arduinomotorshield , slow break in file

Dear arduino-community ,

I have simple setup with two DC-Motors and a Arduinomotorshield. The problem is the file is operating with a sinus curve and toggles and I want to have a slow break for some seconds and than again a slow start.
I tried it with a simple delay, but it is starting after that too fast.

Can anybody help with that? Thank you guys in advance!

faul-shiftmotor2.ino (3.13 KB)

``````  velB = (sin(mill ) + 0.1) * 0.1;        // generate sine wave for motor velocity with an amplitude of 0.0 to 1.0

velB = velB * 15;                          // map sine wave to analog values ( 0.0 … 1.0 ⇒ 55 … 255 )

velA = (sin(mill ) + 0.1) * 0.1;        // generate sine wave for motor velocity with an amplitude of 0.0 to 1.0
velA = velB ;
``````

What the heck? You waste time calculating a new value for velA using the same formula as for velB, and then assign velB to valA. Why on earth would you do that?

It would seem to me that on the second cycle, you'd want to use mill - the time that the cycle takes as the input to sin(), not mill.

The sin() function takes a value in radians, between 0 and 2PI. After mill exceeds 2PI, sin() takes longer because it needs to adjust the input value to be between 0 and 2PI.

Print put some key values to see what is happening.

Hey , thank you for your answer! The first part I understand , but what do you mean with the 0 and 2PI? do I need to make a sin( ) that is so slow that it counts as a break? Could you maybe write it down in C++?

Thanks so much! sorry im pretty new to this;)

what do you mean with the 0 and 2PI?

Are you serious? Do you have a clue what the sin() function does?

do I need to make a sin( ) that is so slow that it counts as a break?

No.

Could you maybe write it down in C++?

No.