flashing police lights

I am fairly new to Arduino and want to code some LEDs to flash and look like police lights. I can code the front and back lights to flash simultaneously, but I can't figure out how to make them flash in different patterns/times, or how to make the top lights(light bar), flash at a different rate/pattern than the others. I looked around and from what I found I concluded that more than one loop is not possible, and I can't wrap my head around how variables work (subtracting/adding to the variables, and resetting it back to zero when it reaches the desired number (1000).
I know what I want it to do, but I don't know how to put it into code:

A = 0(base number)
B = 1(amount added each second)
C = variable (number of seconds)
when C = 10 switch from pattern #1 to pattern #2

(sorry if it did not make much sense, I am not the best at explaining things)
(P.S. I am using a MEGA 2560, if that helps)


Nick Gammon has figured out LOTS of stuff. See:


Scroll down to:

---------------------( COPY )---------------------
Example of flashing lots of LEDs

Following on from a query on the Arduino forum, I've made a class specially designed to flash LEDs at different rates. You can download that as a library from:


Install that in the usual way (unzip into your libraries folder).

I made a similar class to fade up and down LEDs connected to the PWM pins, here:

-----------------( END COPY )----------------------

To learn, you can also look at
Demonstration code for several things at the same time
Using millis() for timing. A beginners guide

Different explanations of the same approach.