Subscribe to Arduino Academy and start learning today for FREE!

The Arduino Powered Lighthouse

I was helping a friend build a 3′ lighthouse, and he felt it could use some “animation”. I suggested a Arduino controlled beacon. We didn’t want to go to the hassle of building a motorized unit, so I designed a simulated rotating beacon. I picked a 3 watt white LED, but since the Arduino can’t control that much current by itself, I used a IRL520 MOSFET. A MOSFET requires a 10k resistor from the gate to ground to turn it off when it’s not active. I connected it to a PWM pin, so I could control the brightness of the LED.

Become the Maker you were born to be. Try Arduino Academy for FREE!

Warning! A 3w LED can pull about 700ma of current at 3.3v, so even though we are only PWM’ing at 50% (except for that 50ms 100% pulse), you should have a separate 1a 3.3v supply.

The sketch below fades the LED in and out, and gives a super bright flash between the ramp up and ramp down, simulating the affect of being in the direct line of the bulb on a rotating beacon,

Enjoy!

 

int cycle=30;
int strobe=cycle*10; // calculate strobe delay
int maxFade=100; // maximum brightness before strobe
int ledPin = 11;    // MOSFET connected to digital pin 11

void setup() {
// nothing happens in setup
}

void loop() {
// fade in from min to max in increments of 2 points:
for (int fadeValue = 0 ; fadeValue <= maxFade; fadeValue += 2) {
// sets the value (range from 0 to maxFade):
analogWrite(ledPin, fadeValue);
// wait for “cycle” milliseconds to see the dimming effect
delay(cycle);
}
analogWrite(ledPin, 255); // simulate a rotating beacon catching your eye
delay(strobe); // hold full brightness for strobe delay
analogWrite(ledPin, maxFade);
// fade out from maxFade to min in increments of 2 points:
for (int fadeValue = maxFade ; fadeValue >= 0; fadeValue -= 2) {
// sets the value (range from 0 to maxFade):
analogWrite(ledPin, fadeValue);
// wait for “cycle” milliseconds to see the dimming effect
delay(cycle);
}
}

Become the Maker you were born to be. Try Arduino Academy for FREE!

 

 

Subscribe
Notify of
guest
6 Comments
Inline Feedbacks
View all comments
Unknown
6 years ago

If I use a 1 Watt LED! Do i still have to use the Mosfet?

Kevin Cox
6 years ago

Could not make it to Work….4 leads from Uno to Board! in the diagramm, only 3 to Board. Could i have Viedo with the LED not On.

Steve Spence
6 years ago

The arduino can source 40ma. The 1 watt LED's are 350ma. Yes, you need the mosfet.

noorse leeuw
5 years ago

Hello a I like it, iTs works with me, but I have a question. Is it possible to chance it so that the light is complily off for a second of so.

Steve Spence
5 years ago

just insert a:

digitalWrite(ledPin, LOW);
delay(1000);

where you want the off period.

Steve Spence
5 years ago

Blue wire not necessary. Not sure why I left that in there. Too long ago. Just need pwr, gnd, and signal (pin 11, yellow wire to MOSFET Gate, per the schematic)

Archives

6
0
Would love your thoughts, please comment.x
()
x