laupilot
Report

Lighthouse

Instruction
IMG_4786.JPEG
IMG_4786
.JPEG
Application scenario
Laser processing
Machine & module
xTool S1
40W
Material used
3 mm playwood
117
1094

Information

      3 mm playwood +Arduino Nano +LDR

https://www.ameede.com/lighthouse-e0021503-file-cdr-and-eps-svg-free-vector-download-for-laser-cut/
    

Instruction

1

Step1

const int groupPins[] = {3, 5, 6, 9};
const int ldrPin = A7;    // Capteur LDR modifié pour utiliser A7
const int threshold = 100;  // < threshold = obscurité


 

const int maxBrightness = 255;
const int fadeStep = 1;
const int fadeDelay = 8;


 

void setup() {
  for (int i = 0; i < 4; i++) {
    pinMode(groupPins[i], OUTPUT);
    analogWrite(groupPins[i], 0);
  }
  pinMode(ldrPin, INPUT);
}


 

void loop() {
  int ldrValue = analogRead(ldrPin);


 

  if (ldrValue < threshold) {
    // Lumière faible → animation phare
    static int current = 0;
    int next = (current + 1) % 4;
    for (int b = 0; b <= maxBrightness; b += fadeStep) {
      analogWrite(groupPins[current], maxBrightness - b);
      analogWrite(groupPins[next], b);
      for (int i = 0; i < 4; i++) {
        if (i != current && i != next) analogWrite(groupPins[i], 0);
      }
      delay(fadeDelay);
    }
    current = next;
  } else {
    // Trop lumineux → tout éteint
    for (int i = 0; i < 4; i++) {
      analogWrite(groupPins[i], 0);
    }
    delay(100);
  }
}
Comments

Remixes

xTool Supplies Used in This Template

xTool S1
xTool S1