delay, but without delay.
arduino uno - Alternative to delay function - Arduino Stack Exchange
Alternative to delay() function Library
Delay Function Alternatives
Videos
// You don't need to return anything since it's just a delay
// also I changed the parameters to long ints because millis()
// returns a long int
void timeLoop (long int startMillis, long int interval){ // the delay function
// this loops until 2 milliseconds has passed since the function began
while(millis() - startMillis < interval){}
}
// Your call for a 2 millisecond delay would be
timeLoop(millis(), 2);
Also the leds may be acting weird because this schematic is wrong. As you can see one of the led's anode isn't connected to ground. It's circled in red.

If you really want it to return something you could use this:
long int timeLoop (long int startMillis, long int interval){ // the delay function
while(millis() - startMillis < interval){}
return millis() - startMillis;
}
But it really isn't needed.
What's the point? Why rewrite delay()?
Anyway:
int timeloop (int interval){ // the delay function
do{
prevmillis = currmillis; //hold previous value
currmillis = millis(); //find current value
time = (currmillis-prevmillis);
}while(time < interval);
return time;
}
In every iteration of that loop you are updating prevmillis. So you will never reach the wanted delay interval.
Apart from the fact that you may as well use the inbuilt delay rather than writing your own, and getting it wrong.
I am trying to make a workaround for the delay function
Why?
The XY Problem
I have a bit of code that is using Delay(100), and it’s causing a bit of problem my dice roller. Is there an alternative to delay to keep the flame like flicker that delay is giving me?
Real embedded systems outside the artificial world of Arduino pretty much never use busy-delays/busy-wait loops as a means to control timing. Such busy-waits are deeply problematic since they stall program execution and cause 100% CPU utilization with 100% current consumption, for no good reasons.
Alternatives used in a professional context involve hardware timers. Either the dedicated timer hardware peripherals, or a dedicated real-time clock hardware peripheral. These can be used either by polling a flag or by interrupts.
For controlling LEDs specifically, "output compare" features of a timer peripheral can be used to automatically activate/deactivate a GPIO pin when a timer runs out. PWM features are also very common, particularly for reducing current consumption or to enable multiple colors in case of RGB.
In either case, any of these various hardware features allow the LED to be controlled in a concurrent manner at the side of the main program.
Whether you're using a busy for loop or the busy-wait delay() function, both are bad.
Study Blink without delay: https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay
For more advanced cooperative multitasking techniques, see my answer here: How to do high-resolution, timestamp-based, non-blocking, single-threaded cooperative multi-tasking
For reading the RC PWM control signal, that's complicated, but I have an old example here: https://github.com/ElectricRCAircraftGuy/PWM_Reader2_WORKS_PERFECTLY_Hayden_car_lights.
Here's the core code. It blinks an LED at a rate proportional to the throttle setting.
YouTube video:
