Hello, I have a basic strobe light setup with my arduino. Right now it is running with only 1 LED, but that could easily be changed with a PSU and more LEDs and some transistors. Or even to an actual strobe bulb, with some additional parts.
Anyways, I am new to Arduino and it's language, so the code is likely messy and ugly and not all is my own, I combined what I read about the example codes and some on the net.
It has a switch connected, so you could turn the flashes off and on, also there is a pot to set the speed the output is flashed, the treshold of the pot could easily be changed in the code.
Would be nice to add another switch, while holding that switch it would burst the output with the max set in the code. Didn't get that far yet, so any suggestions are welcome
I guess it could be usefull for other newbies like my self and maybe some that want to build a cheap strobe light around the atmega chip.
Here is the code:
/*
 Arduino Controlled (LED)Strobe
 This code was made from various example codes that come with the Arduino IDE and some of my own.
Â
 - It has an LED connected to Pin 13 (could use the output with some NPN transistors to hook up an LED arrey)
 - There is a 10K pot connected to Analog 0 (for controlling the off time)
 - There is a switch connected to pin 2 as an input with a 10K resistor (pressing the switch turns on the Strobe, long pressin it turns it off)
 - Can as well monitor the output on the serial monitor
Â
*/
const int sensorPin = A0;Â Â // select the input pin for the potentiometer
const int ledPin = 13;Â Â Â // select the pin for the LED
const int buttonPin = 2; // select the input pin for the switch
int sensorValue = 0;Â // variable to store the value coming from the sensor
int outputValue = 0;
int buttonPushCounter = 0;Â // counter for the number of button presses
int buttonState = 0;Â Â Â Â // current state of the button
int lastButtonState = 0;Â Â // previous state of the button
void setup() {
 // declare the ledPin as an OUTPUT and declare the buttonPin as an INPUT:
 pinMode(buttonPin, INPUT);
 pinMode(ledPin, OUTPUT);Â
 Serial.begin(9600);
}
void loop() {
Â
 buttonState = digitalRead(buttonPin);
 if (buttonState != lastButtonState) {
  // if the state has changed, increment the counter
  if (buttonState == HIGH) {
   // if the current state is HIGH then the button
   // wend from off to on:
   buttonPushCounter++;
   Serial.println("on");
   Serial.print("number of button pushes: ");
   Serial.println(buttonPushCounter);
  }
  else {
   // if the current state is LOW then the button
   // wend from on to off:
   Serial.println("off");
  }
 }
 // save the current state as the last state,
 //for next time through the loop
 lastButtonState = buttonState;
Â
 if (buttonPushCounter % 2 == 0) {
 Â
 // read the value from the sensor:
 sensorValue = analogRead(sensorPin); Â
 outputValue = map(sensorValue, 0, 1023, 25, 1000);
 // 25 is the minimum off time, 1000 is the maximum off time
 // (I think it's in ms, changing these values will change
 // the behaviour of the pot controllin the speed
Â
 Serial.print("sensor = " );          Â
 Serial.print(sensorValue);  Â
 Serial.print("\t output = ");  Â
 Serial.println(outputValue); // turn the ledPin on
Â
 digitalWrite(ledPin, HIGH);Â
 // stop the program for <sensorValue> milliseconds:
 delay(30);    Â
 // turn the ledPin off:   Â
 digitalWrite(ledPin, LOW);Â
 // stop the program for for <sensorValue> milliseconds:
Â
 // print the results to the serial monitor:
 Serial.print("sensor = " );          Â
 Serial.print(sensorValue);  Â
 Serial.print("\t output = ");  Â
 Serial.println(outputValue);Â
 delay(outputValue);        Â
} else {
 digitalWrite(ledPin, LOW);
}
}