Police Lights Project

police lights cover

Task: Create a program to simulate the lights on a police car.

Difficulty: Beginner

Police lights - what you need

For this project you will need:

  • One Crumble with USB lead;
  • A computer with the Crumble software installed;
  • One battery pack with batteries (not rechargeable);
  • Two sparkles;
  • Eight croc-leads.

If making the police car model, you will also need:

  • Printed template;
  • Scissors;
  • Coloured pens/pencils;
  • Glue;
  • Masking tape.



Battery & Crumble

First of all, we need to connect up the battery pack to the Crumble (keep it turned off for now). We need to take care with this as we must make sure that the + on the battery pack goes into the + input of the Crumble, and – on the battery pack connects to the – one on the Crumble.


Battery & Crumble
Sparkle attached

After we’ve connected up the battery pack, we need to add two Sparkles to the Crumble using +, – and D. We need to make sure that the arrow on the Sparkles are pointing to the right (away from the Crumble). Once this is done, we are ready to program!

Police lights basic

Initially, we are going to focus on how to program basic police lights, using the colours Red and Blue. The pattern will look something like this: ⊗ | ⊗ | ⊗ | ⊗⊗ e.t.c. The Sparkles will alternate being on/off; they won’t be on at the same time. To get a Sparkle to flash we need to turn it on, wait, then turn it off again. To get them to alternate, we turn Sparkle(0) on, wait, turn it off. Then we turn on Sparkle(1), wait, and turn it off again. To keep this going, we can put it inside a ‘do forever’ loop. Note: you may want to play around with the ‘wait’ timings, until you find a flash speed that you like.

Police lights basic

Now comes the challenge! Most Police cars have multiple flash patterns for the lights and some even have over 30! Let’s take a look at how we could change this ‘simple’ pattern and make it more interesting.

police lights llrr

This time, we are going to use the following pattern of lights: ⊗ | ⊗⊗ | ⊗ | ⊗⊗ | ⊗ | ⊗⊗ | ⊗⊗ ⊗⊗ etc. For the moment, we are not going to worry about using nested loops. Instead, we will list the instructions for the above flash inside one ‘do forever’ loop.  

police lights nested loop

However, to make the code shorter and more efficient, we can use a loop inside of another loop (nested loops). By doing this, we make it much easier to add in multiple flash patterns. Although in this case it doesn’t look much different, as soon as we start adding different flashing patterns, the benefits become a lot clearer.

police lights nested loop

After we’ve chosen our flashing pattern, It’s time to add some context to the project! We can either add  lights to an existing vehicle, draw a picture of a police car and attach the lights, or we can download and print out our 3D police car model from the ‘Downloads’ section.

We’ve chosen to download our police car template, and after we’ve printed it out we can then add some colour. After this, we need to carefully cut out the template.



We then need to fold along the marked lines and carefully glue it all together.

lights inside car

Finally, we need to attach our sparkles to the inside of the model, underneath the lights. This can be a bit fiddly, but we found that with a bit of patience and some masking tape, we were able to get them to stay put! The paper diffuses the light, and the paper lights on the top of the police car should light up.


And there we have it. A police car with programmable flashing lights!