I am building a computer for my son (me). I'm trying to spark his interest in computer technology, so my idea is to drive multiple case lighting effects with a microprocessor or controller. I went with the arduino over the pi because of simplicity of the system.

There are several lighting effects I want to drive, simultaneously, and that's where I'm wondering if the arduino is well suited, because the effects need to make use of delay(), and with it being single threaded I'm struggling to figure out how to make each output operate independently.

To give you an idea of what the microcontroller needs to drive simultaneously:

  1. Flicker pattern using random delay values for outer case lighting
  2. Heartbeat pattern for CPU cooling block
  3. Blacklight / UV LED lighting for coolant lines.
  4. Strobing LEDs aimed at the fans to make them look stationary.

Trying to run all these effects in a linear loop with delay() operators just doesn't seem to be feasible.

Do I need to get an UNO for each effect? Or is there a way of making these outputs operate independently?


Avoid delay() and use specific times of next actions and compare them to millis(). For a random time, set something like:

if(nextFlicker < now) {
if(nextPulse < now) {
   nextPulse=now+ isPulseOn? 100 : 1000 ;


If you are running more than the 50 day roll-over time of millis(), you may need some care to handle the overflows. See http://playground.arduino.cc/Code/TimingRollover

For the strobing leds, investigate the timer-controlled outputs outputs.


Base the pattern on time, instead of using delays. E.g. if the current time in seconds if odd, the led should be on. If it's even it should be off. This creates a blinking led effect without using any delay.

Some example code:

long seconds = millis()/1000;
if( (seconds % 2)==0 )// even
  digitalWrite(led, HIGH);
else // odd
  digitalWrite(led, LOW);

E.g. to have it blink faster, change 1000 to a lower value.

E.g. to make the led be on shorter than of change %2 to e.g. %4 (i.e. 1 second on, 3 seconds off)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.