Pages: [1]   Go Down
Author Topic: Light house  (Read 756 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

London
Offline Offline
Edison Member
*
Karma: 23
Posts: 1050
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

New Jersey
Offline Offline
Faraday Member
**
Karma: 48
Posts: 3389
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Sitting in the garage.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 451
I made the pretty light blink.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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? 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Leeds, England
Offline Offline
Sr. Member
****
Karma: 8
Posts: 396
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Edison Member
*
Karma: 18
Posts: 1170
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not put in an actual rotating light?
Logged

Leeds, England
Offline Offline
Sr. Member
****
Karma: 8
Posts: 396
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Sr. Member
****
Karma: 19
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
// 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:



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

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Pottstown, PA
Offline Offline
Sr. Member
****
Karma: 4
Posts: 294
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Idaho, US
Offline Offline
God Member
*****
Karma: 19
Posts: 859
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Chicago
Offline Offline
Sr. Member
****
Karma: 5
Posts: 456
With every answer comes more questions.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://www.adafruit.com/products/1463

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...?)


* image.jpg (194.22 KB, 1000x769 - viewed 9 times.)

* image.jpg (132.82 KB, 1000x769 - viewed 11 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: