laupilot
laupilot
Nahlásit

Maják

Návod
IMG_4786.JPEG
IMG_4786
.JPEG
Aplikační scénář
Laserová úprava
Stroj a modul
xTool S1
40W
Použitý materiál
3mm dřevěné dřevo
153
1770

Informace

      3 mm dřevěné dřevo + Arduino Nano + LDR

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

Návod

1

Krok1

const intgroupPins[] = {3, 5, 6, 9};
const int ldrPin = A7;     Capteur LDR modifié pour utiliser A7
const int threshold = 100;<span style="color:#95a5a6;">   < threshold = obscurité


 

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


 

void setup() {
  for (int<span style="color:#4e5b61;"> i = <span style="color:#005c5f;">0<span style="color:#4e5b61;">; i < <span style="color:#005c5f;">4<span style="color:#4e5b61;">; i++<span style="color:#434f54;">)<span style="color:#4e5b61;"> <span style="color:#434f54;">{
<span style="color:#4e5b61;">    <span style="color:#d35400;">pinMode(groupPins[i], OUTPUT);
    analogWrite(groupPins[i], 0);
  }
  pinMode(ldrPin, INPUT);
}


 

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


 

<span style="color:#4e5b61;">  <span style="color:#728e00;">if<span style="color:#4e5b61;"> <span style="color:#434f54;">(<span style="color:#4e5b61;">ldrValue < threshold<span style="color:#434f54;">)<span style="color:#4e5b61;"> <span style="color:#434f54;">{
<span style="color:#95a5a6;">    // Lumière faible → animation phare
<span style="color:#4e5b61;" >    static int current = 0;
    int next = (current + 1) % 4;
<span style="color:#4e5b61;">    <span style="color:#728e00;">for<span style="color:#4e5b61;"> <span style="color:#434f54;">(<span style="color:#00979d;">int<span style="color:#4e5b61;"> b = <span style="color:#005c5f;">0<span style="color:#4e5b61;">; b <= maxBrightness; b += fadeStep<span style="color:#434f54;">)<span style="color:#4e5b61;"> {
      analogWrite(groupPins[current], maxBrightness - b);
      analogWrite(groupPins[next], b);
<span style="color:#4e5b61;">      <span style="color:#728e00;">for<span style="color:#4e5b61;"> <span style="color:#434f54;">(<span style="color:#00979d;">int<span style="color:#4e5b61;"> i = <span style="color:#005c5f;">0<span style="color:#4e5b61;">; i < <span style="color:#005c5f;">4<span style="color:#4e5b61;">; i++<span style="color:#434f54;">) {
       if (i != current && i != next) analogWrite(groupPins[i], 0);
      }
      delay(fadeDelay);
    }
    current = další;
  } else {
    // Trop lumineux → tout éteint
    for <span style="color:#434f54;">(<span style="color:#00979d;">int<span style="color:#4e5b61;"> i = <span style="color:#005c5f;">0<span style="color:#4e5b61;">; i < <span style="color:#005c5f;">4<span style="color:#4e5b61;">; i++<span style="color:#434f54;">)<span style="color:#4e5b61;"> <span style="color:#434f54;">{
<span style="color:#4e5b61;">       analogWrite(groupPins[i], 0);
    }
    delay(100);
  }
}
Komentáře

Remixy

Zařízení xTool použité v tomto projektu

Související kolekce

Související štítky

Licence