Introduction: How to Make a Strobe Light Program in VB.NET

About: exploring, tinkering, DIY(ing), and learning most of what I do

Strobe Light described in this tutorial is designed for slow motion photography, if you don't have access to a physical strobe light or you can't afford one or don't have the materials to make one, you can still make one with the help of programming languages.

The strobe program described here, has an adjustable frequency of upto 5 milliseconds (Actually my computer couldn't manage it below that frequency) and you can choose only one flash color for your strobe.

Step 1: Let's Setup Our Environment First

I coded the strobe in express 2010, the same code would work for vb 2008 and above,

Open Visual Basic and create a new windows form application, then add a 'colordialog' from toolbox to the form it should drop below the form because it works in the background, then add a trackbar, two 'timer's', two 'button's' and 'textbox', Name one of the buttons as choose color and it's name as 'button1' and keep the text property of other button blank , name the blank button 'btn'.

and also add another form to the application; set it's FormBorderStyle to none and WindowState to 'maximised'.

Now the design is complete, So let's move to next step.

Step 2: Let's Code

Now, when our design is done, lets make it alive with code.

Lets begin with the trackbar, double click on the trackbar trackbar1_scroll sub is automatically generated, now type the following code in the sub;

        Timer1.Interval = TrackBar1.Value<br>        Timer2.Interval = TrackBar1.Value
        TextBox1.Text = TrackBar1.Value

Now double click the 'choose color' button, and type the following code in the respective sub;

        ColorDialog1.ShowDialog()<br>        Form2.BackColor = ColorDialog1.Color

Now double click the blank button, and type the following code in the respective sub;

If Btn.Text = "On" Then<br>            Btn.Text = "Off"
        ElseIf Btn.Text = "Off" Then
            Btn.Text = "On"
        End If

Now double click the form1 head and type the following code in the form1_load sub;

Btn.Text = "Off"

Now finally type the following code in timer1 tick event;

Form2.BackColor = ColorDialog1.Color<br>        Timer1.Enabled = False
        Timer2.Enabled = True

And the below code in timer2 tick event;

Form2.BackColor = Color.White<br>        Timer1.Enabled = True
        Timer2.Enabled = False

Now type the following code in the form2's load event;

Me.BackColor = Form1.ColorDialog1.Color

Step 3: Setting Up the TrackBar1

Now single click on the trackbar1 and change the maximum property to 1000 (in milliseconds);it is the maximum frequency of strobe. Also change the minimum property to 5 (in milliseconds), Its because my computer couldn't mange below 5 ms, you may test with your computer, to see which lower value gives good output.

Step 4: Debugging

Press 'F5' on your keyboard or click the small green arrow in the standard toolbar and the application should run,

Now start by first selecting the frequency displayed in textbox1 by sliding the trackbar, select the desired frequency and click on the 'off' button, form2 should pop over everything and flash at the frequency you selected.