laupilot
laupilot
举报

灯塔

教程
IMG_4786.JPEG
IMG_4786
.JPEG
应用场景
激光加工
机器与模块
xTool S1
40W
使用的材料
3毫米的木板
153
1758

信息

      3毫米滑木+Arduino Nano+LDR

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

教程

1

步骤1

const int groupPins[] = {3569};
const int ldrPin = A7;     Capteur LDR modifié pour utiliser A7
const int threshold = 100;<span style=“color:#95a5a6;”>   < threshold = obscurité


 

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


 

void setup()<span style=“color:#4e5b61;”> {
  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;“>pinModegroupPins[i], OUTPUT;
    analogWritegroupPins[i], 0;
  }
  pinModeldrPin, INPUT;
}


 

void loop() {
  int ldrValue = analogReadldrPin;


 

<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 intcurrent = 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 += 渐变<span style=“color:#434f54;”“>)<span style=”color:#4e5b61;“> {
      analogWritegroupPins[current], maxBrightness - b;
      analogWritegroupPins[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 analogWritegroupPins[i], 0;
      }
      delayfadeDelay;
    }
    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;”>      analogWritegroupPins[i], 0;
    }
    delay100;
  }
}
评论

二创

此案例中使用的 xTool 设备

xTool S1
xTool S1

相关集合

相关标签

许可证