Having problem using the millis function!

Hi, I am currently trying to make musical floopy drives and I need to get two or more drives to play different melodies at the same time. I have noticed that the only way to do this is to get rid of all the delays and replace them with "if" tags instead and use the function millis in the loop. I have read every thread there is out there and atleast 7 youtube videos about this subject but I still cant get my own code to work. This is basicly how the part im struggling with at the moment.

I want to call out that when i run the code the floopydrive does indeed move one step, but only one when it should move 10 steps each with 10 milliseconds in between.

int DRIVE = 2;

unsigned long currentMillis = 0;
unsigned long previousMillis =0;

void setup ()

void loop()
currentMillis = millis();

void Floopydrive1()

void DRIVE1note10(int count){ //this is a premade note that I made
while(count > 0)
if (currentMillis >= 10 + previousMillis) // after 10 milliseconds the DRIVE will turn to high and that will make the motor on the floopy drive to move 1 step forward.
digitalWrite(DRIVE,HIGH); previousMillis = currentMillis; count= count -1; //resets so that it will take another 10 milliseconds before it enters the "if" function again.

digitalWrite(DRIVE,LOW); // when there haven't been 10milliseconds yet the motor will be on LOW.

The demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Always use subtraction when testing for a time interval. Rather than

  if (currentMillis >= 10 + previousMillis)


  if (currentMillis - previousMillis >= 10)

to avoid problems when millis() rolls over.


You need to update the value of currentMillis in the while loop

I am no musician, but typically I hear things like a 3-4 beat… think it means that you hit a key on the piano, every so often.

not sure if you can break your whole score into increments but when using millis() as a timing, one often either resets it every time it reached a point, our uses it as a counting metronome.

now = millis()- then
if ( now >= 100 microSeconds)
counter ++
then = millis() // resets once it incremented the counter

if (counter = = 1545 ){ DRIVE1note10(10); }
if (counter = = 1820 ){ DRIVE2note12(20); }
if (counter = = 2260 ){ DRIVE4note8(12); }