SIMPLE STROBESimpleStrobe-1024.jpg

This sketch uses a potentiometer to change the speed of a Strobelight that uses LEDs. Example on right uses the YourDuino RoboRED (Comes with free cables like those shown) and the BRIGHT! White 3 Watt LED and the Slide Potentiometer (Click).

You can use other potentiometers of 1K ohms to 100K ohms, and other not-so-bright LEDs, but you'll need a fairly dark room and close spacing to see the strobe effect. With other LEDs use a small value series resistor such as 100 ohms, or two 200 ohms in parallel. Also notice that TWO pins (12 and 13) can be used for LEDs.

The adjustable timing Strobe Light can make rotating wheels, fans etc. appear to "stop". Falling series of drips can be made to appear stopped. See:

(Copy and Paste into a blank Arduino IDE Window)

/* YourDuinoStarter Example: Controllable Time Strobe LED V3
 - WHAT IT DOES: Flashes an LED with variable timing set by a potentiometer
   - Can "stop" motion of rotating wheels, fans etc.
   - Works best with a High Output LED like this:
 - INFO: See  
 - SEE the comments after "//" on each line below
   - LED: Pin 13
   - Potentiometer: Pin A2
 - V1.06 05/31/2015
   Questions: */

/*-----( Declare Pin Numbers )-----*/

#define potentiometerPin 2   // Pot connected to Pin 2 will control strobe speed.
#define ledPin           13  // Same as the small built-in LED, also use for separate bright LED
#define otherLedPin      12  // Optional for more LEDs, not-so-bright LEDs

/*-----( Declare Constant Values )-----*/

// Set the minimum delay between flashes in milliseconds (thousandths of a second)
#define minDelay  1   // 1/1000 of a second

#define maxDelay  200  //SO: That's 200/1000 right? 1/5 of a second. 5 flashes per second.

// How long should the each flash be?
#define onTime  500    //SO: 500/1000000 hmm.. reduce fraction: .5/1000  1/2 of 1/1000 of a second

/*-----( Declare Variables )-----*/

int potPosition ;  // Value from analogRead of the pot.  Values from 0..1023 
int strobeDelay ;  // How long between flashes? Changed by Pot position

void setup()   /****** SETUP: RUNS ONCE AT THE BEGINNING ******/
  pinMode(ledPin,      OUTPUT); // Set up ledPins as an output.
  pinMode(otherLedPin, OUTPUT); 
}//--(end setup )---

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
  potPosition = analogRead(potentiometerPin);  // Read the pot position
  // convert the 0 to 1023 range we get from analogRead, into our strobe delay range of 1 to 200 
  strobeDelay = map(potPosition, 0, 1023, minDelay, maxDelay);

/*---( Blink the LED ON and OFF )-----*/
  digitalWrite(ledPin,      HIGH); // Switch the ledPin to HIGH, turn it on!
  digitalWrite(otherLedPin, HIGH); // Switch the ledPin to HIGH, turn it on!  
  delayMicroseconds(onTime); // Delay while on, for onTime.
  digitalWrite(ledPin,      LOW); // Switch the ledPin to LOW, turn if off!
  digitalWrite(otherLedPin, LOW); // Switch the ledPin to LOW, turn if off!  
  delay(strobeDelay); // Delay while off, for strobeDelay

}//--(end main loop )---

//*********( THE END )***********