: Circuit Analysis
Figure 1 shows the schematic diagram of the device. The heart of this circuit is an STM8S001 microcontroller.
Figure 1, Schematic diagram of the programmable police LED-Flasher
Let’s start the analysis from the power supply unit. C2 and C3 are used to reduce the input voltage noises. Then the voltage is handled to the 78M09  (REG1) regulator. It is used to stabilizes the voltage at 9V. C4 and C6 are used to reduce the regulator’s output noises.
The output of the REG1 is handled to a first-order RC filter (R28 and C5). It helps to reduce the noises even further because this device might be used continuously in a noisy environment such as a vehicle. The best way to examine the behavior of this filter (or other filter types) is to perform a practical measurement. The SDS1104X-E oscilloscope introduced a nice bode plot feature that can perform this useful calculation.
REG2  is used to convert 9V to 5V to supply the STM8s001 MCU  (IC1). C7 is a supplementary filtering capacitor for the IC1.
IC1 MCU is programmed using a single SWIM wire. It stands for the Single-Wire Interface Module. It is a high-speed link between the MCU and the programmer/debugger. This pin must be connected to the SWIM pin of the programmer/debugger. The ground pin must also be connected. This completes the connection (P2).
IC2 and IC3 are logic N-Channel SMD Mosfets  that are used to turn on/off the LEDs. The gate pins of both MOSFETs have been pulled down using 4.7K resistors to avoid unwanted triggering (R13, R14). SW1 is a tactile push button that is used to switch between flasher programs. R27 is a pull-up resistor and C8 reduces the possible push-button debouncing noises.
R1 to R26 resistors are used to limit the LEDs current. In each part, I have put 3 LEDs in series that are connected to the +9V rail (Figure 2). The characteristics of LEDs vary from manufacturer to manufacturer. Therefore we can not assign a fixed limiting series resistor for all circumstances. The maximum tolerable current of a 5mm LED is around 25mA. Therefore the resistor value that could limit the current to somewhere around 15mA (a bit higher than a half) looks sufficient and does not affect the LEDs’ lifetime and does not significantly decrease the LED brightness.
You can start from a 100-Ohm resistor and increase it and simultaneously monitor the current. In my case, I read 15mA by using a 180-ohm resistor.
Figure 2, Finding the best resistor value for the series LEDs
: PCB Layout
Figure 3 shows the PCB layout of the flasher (last revision). It is a single layer PCB board. Except for LEDs, all components are SMD and soldered on the copper side.
In the design process of this schematic and PCB, I used several pre-made libraries from SamacSys. IC1 , IC2 , IC3 , REG1 , and REG2  are installed using the SamacSys libraries and its Altium Designer plugin  (Figure 4). It saved a lot of my design time. I always make mistakes when I design the libraries from scratch that ruin my day and PCB prototypes. These libraries are free and more importantly, they follow IPC footprint standards.
Figure 3, The PCB layout of the Police-Flasher circuit (last revision)
Figure 4, Selected components in the SamacSys Altium plugin
Figures 5 and 6 show the 3D views of the final revision of the PCB board.
Figure 5, A 3D view of the PCB board from the top (last revision)
Figure 6, A 3D view of the PCB board from the bottom (last revision)
Picture 7 shows an image of the first tested PCB prototype. I ordered it on the PCBWay and I got 5 boards at the same price. As you can see the build quality is fine.
In the last revision, I have modified some component footprints (all are SMD except LEDs) and moved the supply wires to the bottom side. You will solder the 12V supply wires directly on the PCB board.
Figure 7, The first prototype of the flasher board... Read more »