Summary of Arduino Police Strobe Light Code
This article describes an Arduino project to create a police strobe light effect using red and blue LEDs. The blinking speed of the LEDs is controlled via a 10kΩ potentiometer connected to an analog input, which adjusts the delay between LED flashes. The circuit uses two red and two blue LEDs, each paired with 330Ω resistors, connected to digital pins 11 and 12 on the Arduino. The project is a simple variation of the basic blink code, mapping potentiometer input values to control the strobe timing from 10ms to 500ms.
Parts used in the Arduino Police Strobe Light effect:
- 2x 5mm red LED
- 2x 5mm blue LED
- 1x Arduino
- 4x 330Ω resistor
- 1x 10kΩ potentiometer
- Jumper wire
Arduino Police Strobe Light effect, another simple variation of blink code.
Arduino Police Strobe Light effect, another simple variation of blink code.
Parts List;
1) 2x 5mm red LED
2) 2x 5mm blue LED
3) 1x Arduino
4) 4x 330Ω resistor
5) 1x 10kΩ potentiometer
6) Jumper wire
Instruction;
1) Connect all LED as diagram below, make sure cathode lead of LED at ground wire.
2) Connect all 330Ω resistor to anode lead of LED.
3) Connect all jumper wire to digital pin 12 and 11.
4) Connect 10kΩ potentiometer as shown and center lead connect to analog 0 pin.
Upload this code to your arduino
/* Police Strobe Light Create police strobe light effect with speed control of the blink. Coded by: arduinoprojects101.com */ const int analogInPin = A0; // Analog input pin that the potentiometer is attached to int sensorValue = 0; // value read from the pot int timer = 0; // delay value void setup() { // initialize the digital pin 12, 11 as an output. pinMode(12, OUTPUT); pinMode(11, OUTPUT); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map sensorValue reading to match timer delay between 10ms to 500ms timer = map(sensorValue, 0, 1023, 10, 500); digitalWrite(12, HIGH); delay(timer); digitalWrite(12, LOW); delay(timer); digitalWrite(12, HIGH); delay(timer); digitalWrite(12, LOW); digitalWrite(11, HIGH); delay(timer); digitalWrite(11, LOW); delay(timer); digitalWrite(11, HIGH); delay(timer); digitalWrite(11, LOW); }
This arduino projects, is another variation of blink code. delay value controlled by timer constant.
const int analogInPin = A0;
declare where analog input pin from 10kΩ potentiometer, that is analog pin 0 (A0).
sensorValue = analogRead(analogInPin);
reading analog value from analogInPin (A0), analog input reading will give 0 to 1023 integer value.
timer = map(sensorValue, 0, 1023, 10, 500);
timer constant use to control speed of the light strobe blinking. map is use to match analog reading (0~1023) with delay (10ms-500ms). If analog reading is 0, this will map 10ms as delay time, if analog reading is 511, this will map 250ms as delay time and so on.
Source : Arduino Police Strobe Light Code