laupilot
laupilot
Reportar

Faro

Instrucción
IMG_4786.JPEG
IMG_4786
.JPEG
Escenario de aplicación
Procesamiento láser
Máquina y módulo
xTool S1
40W
Material utilizado
Playwood de 3 mm
154
1782

Información

      Material de juego de 3 mm +Arduino Nano +LDR

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

Instrucción

1

Paso1

const int groupPins[] = {3, 5, 6, 9};
const int ldrPin = A7;     Capteur LDR modifié pour utiliser A7
const int threshold = 100;<span style="color:#95a5a6;">   umbral de < = 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 siguiente = (actual + 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 != actual && 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);
  }
}
Comentarios

Remixes

Suministros de xTool utilizados en este proyecto

xTool S1
xTool S1

Colecciones relacionadas

Etiquetas relacionadas

Licencia