Skip to main content

LED Strobe Light

I ordered a small strobe light more than a month ago from china, but it wasn’t delivered in time, so I made one from a LED light I had at home.

First, I wired this LED light through a NPN transistor. It couldn’t be wired directly to Arduino because it requires higher current than Arduino can provide. I’ve also wired a 10K Potentiometer for tuning the frequency of blinking.

Wiring diagram

Resistor wired from pin 2 is 1K Ohm and the pulldown resistor connecting transistor to the ground is 10K Ohm.

Wiring
Wiring

Programming everything was as simple turning pin on and off with delays in between linked to potentiometer. At higher frequencies I noticed that light was actually lit longer than it was off so the effect wasn’t as good as I expected it to be.

I had to adjust the delay before light turns on again to be longer at higher frequencies, but stay about the same at higher. I drew a graph time on-time off to represent this and figured out I could shift and stretch function y = -1/x to form the same line. The results were much better then.

Graph
Graph

A clip of the strobe light working.

Here is the code for Arduino.

int potPin = 2;    // input pin for the potentiometer
 int ledPin = 2;   // pin for the LED
 int val = 0;      
 int onTime = 0;
 int offTime = 0;
 void setup() {
   pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT 
 }
 void loop() {
   val = analogRead(potPin); // read the value from the potentiometer (10k Ohm) (approximately between 0 and 1000)
 onTime = val;
   offTime = (-2000000 / (onTime + 1000)) + 2000;
 onTime = onTime / 4;    //
   offTime = offTime / 4; // Intervals longer than 250ms were not useful for application, also makes potentiometer less sensible, so I could fine tune desired frequencies.
 if (onTime > 12)  { //keeps light off if potentiometer set to min
     digitalWrite(ledPin, HIGH); }
   delay(onTime);                  // how long the LED stays On
 if (onTime < 250){ //keeps light on when potentiometer set to max
     digitalWrite(ledPin, LOW); }
   delay(offTime);                  // how long the LED stays Off
 }