Light house

My wife loves Light Houses and for her birthday I thought about making one for the front yard. Can someone help with a sketch that would simulate the flash of the light? Looking for something that would fade up to about 80 percent, then 100 percent (flash), go back to 80 percent and fade to out and repeat.
Dave

Look up Pulse Width Modulation (PWM) to see how to fade a light.

Take a look at the fade example that comes with the IDE.

If it is going to be outside, maybe you would want a light dependent resistor or a phototransistor so the light house only comes on at dusk and shuts off in the day, like a garden light.

Battery powered or hard wired 12v?

I can make a fading sketch but what I wanted was instead of the 0 to 100 percent and back down to 0, I wanted 0 to 80 percent and then it would jump to 100 percent back to 80 and down to 0. This would give the light a fade up and a simulated FLASH at peak of the cycle. I did a test with a standard fade sketch but would like to see that FLASH. I plan to use 12vdc power supply using 3 10 watt LED going through a transistor.

Try incrementing from 0 to 50 then jump to 100. Light output isn't linear to our eyes!

Why not put in an actual rotating light?

Because then it would be like the old emergency service lights. Lighthouses use a system of lenses and mirrors to give an intense burst of light.

// untested code

const byte lightPin = 3;          // Must be a PWM pin
const int fadeRate = 10;        // MilliSeconds between fade increments or decrements
const int fadeThreshold = 205;  // 80% of 256
const int flashDuration = 1000;

void setup()
{
  pinMode(lightPin, OUTPUT);
}

void loop()
{
  int fadeLevel;

  for (fadeLevel = 0; fadeLevel <= fadeThreshold; ++fadeLevel)
  {
    analogWrite(lightPin, fadeLevel);
    delay(fadeRate);
  }
  analogWrite(lightPin, 255);
  delay(flashDuration);
  for (fadeLevel = fadeThreshold; fadeLevel >= 0; --fadeLevel)
  {
    analogWrite(lightPin, fadeLevel);
    delay(fadeRate);
  }
}

You can mess with the fadeRate and fadeThreshold to make it look like what you want.

That's a nice first try, but I don't think it would look too much like a real lighthouse. I'm not sure you really want it to look like a real lighthouse, though. I understand real lighthouses have varying flashes to identify the specific lighthouse. I suggest this effect instead:

this effect

Probably not real, but I think your wife would like it better.

Why not make the model lighthouse use an actual rotating light, just like a real lighthouse uses?

Basically - go to one of those "party stores" and get a rotating party light, like this one:

http://www.bewild.com/baopledpolib.html

Remove the colored cover, and install it in your "lighthouse". Hook the motor that drives the mirror to a motor controller so you can change the speed with PWM (most of these party lights rotate much quicker than would look proper for a lighthouse).

If you didn't have any other use for the Arduino (for instance: sound effects, other light controls for the lighthouse model, etc), you could drop it, and just buy one of those simple motor/speed controller kits based on a 555 timer and NPN transistor (and, if you understand that part - you can probably easily make one yourself).

I have given some thought to a lighthouse project. What I had in mind to do was to have the lighthouse have 4 curved faces. Each face would have 3 leds in a row. The first led being a warm white led ramping up to full power followed by the middle, high intensity led flashing then the third, warm white led ramping down. The next face's 'first' warm white led would start it's ramp up while the previous face's 'third' warm white led is ramping down. All this done via a TLC5940 and a 328P micro controller.

Would look cool on top of this, eh?

  • Scotty

I count 12 LEDs, but the Atmega328P has only 6 hardware PWM outputs. Using the SoftwarePWM library is probably the easiest solution here.

You mention high intensity LEDs -- you'll need to use a transistor on each or one or more TPIC6B595 or similar helper chips, as the Arduino is not able to control power-hungry devices directly.

I believe there is even a ShiftPWM library if you go the TPIC route.

This has 16 (VERY BRIGHT) fully dimmable, individually controlled, RGB LEDs, is already in a circle, and can be controlled with one Arduino pin. And, they have a library you can use to very easily program the effect you're after.

They face up instead of out....but, you could just put something reflective in the middle to redirect light output? (Mylar cone, PVC tube, etc...?)

TanHardon, that sketch hit the ball out of the park! Just a few tweaks and it is perfect!
Thanks
Dave