laupilot
laupilot
Segnala

Faro

Istruzione
IMG_4786.JPEG
IMG_4786
.JPEG
Scenario di applicazione
Elaborazione laser
Macchina e modulo
xTool S1
40W
Materiale utilizzato
Playwood da 3 mm
153
1765

Informazione

      Legno da gioco da 3 mm +Arduino Nano +LDR

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

Istruzione

1

Passo1

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


 

const int maxBrightness = 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 = next;
  } 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);
  }
}
Commenti

Remixes

Forniture xTool utilizzate in questo progetto

Collezioni correlate

Tag correlati

Licenza