
Video
Circuit Diagram

Source Code
1int delayTime = 60;
2void setup() {
3 pinMode(2,OUTPUT);
4 pinMode(3,OUTPUT);
5}
6void loop() {
7 for(int i=0;i<3;i++){
8 digitalWrite(2,HIGH);
9 delay(delayTime);
10 digitalWrite(2,LOW);
11 delay(delayTime);
12 }
13
14 for(int i=0;i<3;i++){
15 digitalWrite(3,HIGH);
16 delay(delayTime);
17 digitalWrite(3,LOW);
18 delay(delayTime);
19 }
20}FAQ
How can I make the strobe effect look more realistic?▾
Real police lights flash briefly a few times in every color. If you use a `for` loop to quickly turn on one LED three times (e.g., 50 ms on, 50 ms off) and then move on to the next one, you’ll get an effect that closely resembles a police light.
Can a red and a blue LED use the same resistor?▾
They work, but their brightness will differ: the forward voltage of the blue LED (about 3.2 V) is higher than that of the red one (about 1.9 V), so less current flows through them with the same resistor. To achieve the same brightness, you can choose a lower resistance for the blue LED; the LED resistance calculator performs this calculation.
What is the purpose of the "for" loop here?▾
This is used to repeat the same blinking pattern a specific number of times. Instead of copying and pasting the code multiple times, you can control the repetition from a single location by writing `for (int i = 0; i < 3; i++)`.
What can I use to make the flash brighter?▾
An Arduino pin can supply a maximum of approximately 20 mA. For more powerful LEDs or LED strips, you need to drive them from a separate power source using a transistor (e.g., BC547 or MOSFET); do not connect high-current loads directly to the pin.
