Vex cortex anyway to have a random number genator for the motor?

I am trying to have a random generated number for the motor speed. I tried using Ran and srand, but none of them have worked. Any ideas of how I can do this?

#pragma config(Sensor, dgtl11, button1, sensorTouch)
#pragma config(Sensor, dgtl12, button2, sensorTouch)
#pragma config(Motor, port1, rightMotor, tmotorVex393_HBridge, openLoop, driveRight)
#pragma config(Motor, port10, leftMotor, tmotorVex393_HBridge, openLoop, reversed, driveLeft)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

float a;
float randTime;

task main()
{
while(1 == 1)
{

	a=srand(1);


	randTime = (a * 8000) + 1400;
	if  (randTime>8000)
	{

		randTime= randTime -  2000;
	}

		motor[rightMotor]= 50;
	motor[leftMotor]= -50;
	wait1Msec(randTime);
	motor[rightMotor]= 0;
	motor[leftMotor]= 0;
	wait1Msec(1000);
}

}

4 Likes