#151
Raspberry Pi Pico Police Strobe Light Effect (Red + Blue, GP11 + GP12)
Simulate a police car strobe light with Raspberry Pi Pico! 🚨 Red and blue LEDs flash 3 times rapidly (50ms strobe), then switch colors. This fast toggle creates the classic "police strobe" effect. Learn a new concept: **parameterized function** — `def strobe(led, count, duration_ms)` strobes any LED with any count and duration. No code repetition — same effect for both red and blue. Also `sleep_ms()` — millisecond precision, more accurate than `sleep()`. Very simple circuit: GP11 (red) + GP12 (b
0.0(0)

Simulate a police car strobe light with Raspberry Pi Pico. Red and blue LEDs flash 3 times rapidly (50ms strobe), then switch. Learn parameterized function and sleep_ms(). Simple circuit: GP11 (red) + GP12 (blue) with 220Ω resistors.
Circuit Diagram

Source Code
1# ─────────────────────────────────────────
2# BlueGrays · bluegrays.com
3# Pico Polis Cakar Basit / Simple Police Alternating (GP11 + GP12)
4# ─────────────────────────────────────────
5# TR: 2 LED alternatif flip-flop — kirmizi yanarken mavi soner
6# EN: 2 LEDs alternating flip-flop — red on while blue off, then swap
7
8from machine import Pin
9from time import sleep_ms
10
11# ============ PIN / PIN ============
12kirmizi = Pin(11, Pin.OUT) # TR: Kirmizi LED | EN: Red LED
13mavi = Pin(12, Pin.OUT) # TR: Mavi LED | EN: Blue LED
14
15BEKLE_MS = 300 # TR: Renkler arasi bekleme | EN: Switch delay (ms)
16
17print("== BlueGrays · bluegrays.com ==")
18print("Polis Cakar Basit / Simple Police Alternating")
19print("Kirmizi: GP11 | Mavi: GP12")
20
21# ============ ANA DONGU / MAIN LOOP ============
22while True:
23 # 1) Kirmizi yak, mavi sondur
24 kirmizi.value(1)
25 mavi.value(0)
26 print("[FLIP] KIRMIZI / RED")
27 sleep_ms(BEKLE_MS)
28
29 # 2) Mavi yak, kirmizi sondur
30 kirmizi.value(0)
31 mavi.value(1)
32 print("[FLIP] MAVI / BLUE")
33 sleep_ms(BEKLE_MS)
34