- https://customer-rww76yind8iym5aw.cloud ... e00/iframe
- https://blog.jgc.org/2022/12/sea-glass- ... light.html
- https://github.com/jgrahamc/sea_glass/b ... _glass.ino
海玻璃呼吸灯
- shaoziyang
- 帖子: 3919
- 注册时间: 2019年 10月 21日 13:48
Re: 海玻璃呼吸灯
参考代码
代码: 全选
// sea_glass
//
// Copyright (c) 2018 John Graham-Cumming
//
// Makes four LEDs from an AdaFruit NeoPixel strip "breath" in white
// as part of a small lamp made from a glass and white, green and brown
// pieces of sea glass found on a beach.
#include <Adafruit_NeoPixel.h>
#define PIN 0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
}
// Formula for breathing from...
// https://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
void loop() {
float val = (exp(sin(millis()*0.5/2000.0*PI)) - 0.36787944)*108.0;
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(val, val, val));
}
strip.show();
}
-
- 随机主题
- 回复总数
- 阅读次数
- 最新文章
-
- 13回复总数
- 882 阅读次数
- 最新文章 由 czfx
2023年 3月 26日 06:11
-
- 3回复总数
- 339 阅读次数
- 最新文章 由 zwjiang
2023年 3月 27日 08:48
-
- 8回复总数
- 515 阅读次数
- 最新文章 由 zhoukang8888
2023年 3月 27日 19:34