Anton
Published © CC BY-NC-SA

Lighthouse 3D Print and Arduino

Got a 3D printer and a spare Arduino Uno or Mega? Make a working lighthouse for your home.

IntermediateShowcase (no instructions)20 hours5,791
Lighthouse 3D Print and Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LED (generic)
LED (generic)
×2
20-Watt Halogen T3 12-Volt G4 Capsule Dimmable Light Bulb
×1
SparkFun Toggle Switch
×1
12v Power Supply
×1
Resistor 10k ohm
Resistor 10k ohm
×1
220-Ohm Resister
×2
N-Channel MOSFET 60V 30A
×1
DC Barrel Jack Plug
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Lighthouse Arduino Wiring

Wiring diagram for the Arduino and lights.

Code

Lighthouse Sketch

Arduino
Arduino sketch to control the lights flashing in the lighthouse
// Lighthouse sketch for 3D printed lighthouse project
// By Anton

int topLed = 13;
int middleLed = 9;
int bottomLed = 11;
int brightness = 0;
int fadeAmount = 5;
int value1 = LOW;
int value2 = HIGH;

long time1 = millis();
long time2 = millis();
long interval1 = 1000;
long interval2 = 30;

void setup() {
  pinMode(topLed, OUTPUT);
  pinMode(middleLed, OUTPUT);
  pinMode(bottomLed, OUTPUT);
}

// Control LEDs
void loop() {
  unsigned long m = millis();

  analogWrite(middleLed, brightness);
  digitalWrite(bottomLed, value2);

  // blink the RED led
  if (m - time1 > interval1) {
    time1 = m;

    if (value1 == LOW) {
      value1 = HIGH;
    } else {
      value1 = LOW;
    }
  }

  // Fade the middle light
  if (m - time2 > interval2) {
    time2 = m;
    brightness = brightness + fadeAmount;
    if (brightness == 0 || brightness == 255) {
      fadeAmount = -fadeAmount;
    }
  }

  digitalWrite(topLed, value1);
}

Credits

Anton

Anton

5 projects • 37 followers
Time traveler, developer; special interest in black holes and bending space time

Comments