if ((millis() - rotor_block) >= 1) //Keep the current flow for 3 milliseconds.
{
rotor_block -= 1;
if (!rotor_block)
{
rotor_block = 30;
When rotor_block is set to 30 your 'if' means "has it been more than 31 milliseconds since the sketch started?" I don't think that is what you are trying to do. You should record the value of millis() when the timer starts and compare (millis() - startTime) to the interval length to see if the interval has expired. If you want the timer to be something you can turn on and off:
. static unsigned long startTime = 0;
if (startTime != 0 && (millis() - startTime) >= interval)
{
// This gets executed 'interval' milliseconds after startTime is set to millis()
startTime = 0; // Turn off timer.
}
Maybe you want something like this:
. static unsigned long rotorBlockStartTime = 0;
const unsigned rotorBlockInterval = 30;
if (rotorBlockStartTime != 0 && (millis() - rotorBlockStartTime) >= rotorBlockInterval)
{
// This gets executed 'rotorBlockInterval' milliseconds after rotorBlockStartTime is set to millis()
rotorBlockStartTime = 0; // Turn off timer.
}
.
.
.
rotorBlockStartTime = millis(); // Block rotor for rotorBlockInterval