I'm trying to understand how to incorporate A random statement into a Millis function I have set up for random sounds to add a motor movement.
I have a motor where I am using a tb6612fng, to rotate a motor on my robot. In my sketch I use the Millis function to have a random sound play via a DFplayermini every min, and I want that to correspond with a head movement. perhaps using something like:
randomSeed( analogRead(A0) );
(trying to Keep it truly random)
After I added the movement into the statement, I realize its to structured and I'd like to to do one of maybe a few pre-programed movements.
can someone help explain to be a good way and how I would set-up a group of set movements and use random within the millis statement to call upon one of these?
example of the Motor statements I'd like to be random:
//Movement one:
motor1.drive(255,200);
motor1.drive(-255,200);
//Movement two:
motor1.drive(-255,200);
motor1.drive(255,200);
My millis statement I'd like the random movement to happen within:
const unsigned long eventInterval = 60000; // 90000= 1.5 min change value to change chatter time
unsigned long previousTime = 0;
int randomInt;
unsigned long currentTime = millis();
if ( currentTime - previousTime >= eventInterval) { // delay event for R2s "chatter" sounds folder 01
randomInt = random(1, 144); //number of tracks in folder on Sd card
myMP3.playFolder(1, randomInt); //Plays random track from dfplayer
previousTime = currentTime;
}