Go Down

Topic: Servo Randomizer with ease problems... (Read 410 times) previous topic - next topic


Hello everyone.

 I am very new to programming and I am doing my best here, so forgive me if this is sub-standard work. Here is my issue. I am trying to set a random value for a servo, then use an ease function to chase the random value with the servo position. When the servo position value is reached, set a new random position, and lather, rinse, repeat. I have tried about four thousand variations of this and keep getting the serial port reporting lots of zeros. Does anyone see what I am doing wrong? I suspect that I will need to eventually define a zone as being close enough to the number to be seen as that number so the division doesn't go on infinitely, but I would be happy right now seeing some of the values change as they get closer to the servo position asked for by the random number.

 Here is the code.
Code: [Select]
#include <Servo.h>

Servo servo1;
float spd = 2;
float ran = random(0,180);
float ease;
float current;
float noopos;

void setup()

void loop()
if (servo1.read() != ran)
 current = servo1.read();
 noopos = (ease - current);

   ran = random(0,180);

 Hopefully someone will have some insight. I tried using the delay function to reduce the speed of the servo, but it was choppy and ugly, so I am hoping this is a better way to get the results I am looking for. Thanks in advance for any information/insight on this problem.



Go Up