回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页
best-icon

REMAKE Mini可充电雷雨云 中等

头像 小含糊online 2021.01.06 1305 5
project-image

这是之前在论坛上看到的@源代码前辈做的项目,原作品来自设计师Richard Clarkson之手。不得不说,@源代码前辈真的好厉害,写的帖子都非常非常棒!从他那里可以学到很多有用的东西!也再次感谢咱们DF论坛这个大平台!

这是一个有趣的雷雨云,把它悬挂在卧室,当有人经过的时候,会播放出雷雨声,并且云朵中会有“闪电”出现哦!@源代码 前辈更是在程序中加入了随机出现的七彩祥云,非常有趣!

这个项目我去年暑假在逛论坛的时候发现的,第一眼就爱上了!当时就回帖表示一定要学着做一个,这次也算是交作业了~

整个制作过程不难,但是步骤比较多,中间也经历了一些小插曲,万幸最后勉强成功了,当然后面还有很多需要改进的地方,因为临近期末,事情比较多,所以打算寒假抽空进行修改。

我们一起来看看效果吧!(b站视频)

接下来就一起看看这朵云的制作过程吧!

材料清单

  • WS2812 LED灯带 X1
  • DFPlayer Mini 播放器模块 X1 链接
  • 小喇叭 X1 链接
  • 1路5V继电器驱动模块 X1
  • 人体热释电红外传感器 X1
  • DC-DC 直流升压模块(5V) X1 链接
  • Arduino Pro mini X1
  • 自锁开关 X1
  • 洞洞板若干 X1
  • 棉花若干 X1
  • 导线若干 X1
  • 发光二极管若干 X1
  • 废弃瓶子 X1
  • 热熔胶枪 X1
  • 22Ω电阻若干 X1
  • 电源接头 X1
  • 排针若干 X1
  • 锂电池 X1
  • 内存卡 X1
  • 16v330uF电容 X1
  • 热缩管若干 X1

电路图还是用@源代码前辈的吧,自己试着画了一下,远没有前辈画的清楚明了!

project-image

接下来是制作步骤:

第一步:码好器材

project-image
project-image

第二步:依照电路图焊接电源

这里电容用错了……哈哈哈哈啊哈,我真粗心……

project-image
project-image

第三步:测试元器件

这里重点测试了ws2812灯带和升压模块。

一开始在X宝买的,是坏的,捣鼓半天我以为自己哪里出了问题,后来用了DF商城的发现是模块质量问题……

所以这里建议大家如果模块不贵的话,可以多准备几个进行测试。

ws2812灯带我没有买DF商城的,手里银子有限,所以我在X宝买的,效果还不错,这里一定注意,调试的时候一定把程序中灯珠的数量写对了,切记!

project-image
project-image

第四步:制作云身,连接电路

一开始我打算用塑料瓶来做身体,可是因为塑料瓶有点大,灯带灯珠数量没那么多,做出来效果不好,于是果断换成了易拉罐,这里温馨提醒朋友们,一定注意安全啊!我用煤气灶把手烫伤了……

关于灯带的问题——这里是要把灯带自行剪断,然后使用电线再连接起来的,在焊接的时候一定要注意信号端口,还有不要过热,过热会烧坏灯珠,我的灯珠都……………………

如果灯珠烧坏了没事,把那一节减掉就好,只是尽量不要长时间给一个点加热焊接就好!

project-image
project-image
project-image
project-image
project-image

第五步:整理布线

可以使用胶带或者扎带,让电线不要那么杂乱无章

project-image
project-image

第六步:制作云身体

1.使用胶枪、胶带把灯带固定好

2.使用胶枪胶带把棉花往易拉罐上面粘!注意热熔胶不要太多,否则会因为重量的问题让云多边形

3.注意人体热释传感器的位置

project-image
project-image

第七步:编写程序。这里是代码,代码我是参考的@源代码 前辈的代码,后续想把它改进一下,再试着能不能转换成小朋友可以轻松读懂的图形化代码

代码
#include <Adafruit_NeoPixel.h>
       
 
    #define PIXEL_PIN    6  //灯条链接引脚
    #define SENSOR_PIN   9  //传感器链接引脚
    #define SPEAKER_PIN  13  //继电器模块的引脚
 
    #define PIXEL_COUNT 32  //灯珠的个数
 
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
 
    int randomNumber;
 
 
 
 
 
 
    void setup() {
      pinMode(SPEAKER_PIN, OUTPUT);
      digitalWrite(SPEAKER_PIN, LOW);
      strip.begin();
      strip.show(); 
 
      pinMode(SENSOR_PIN, INPUT);
      randomSeed(analogRead(0));
      
      Serial.begin(9600);
 
    }
 
    void loop() {
      
      
      if( digitalRead(SENSOR_PIN) == HIGH){
        digitalWrite(SPEAKER_PIN, HIGH);
        randomNumber = random(300);
        Serial.println(randomNumber % 67);
        thunder_strike(randomNumber % 67);
     
        delay(3000);
        digitalWrite(SPEAKER_PIN, LOW);
 
      }else{
 
        if(millis() % 100000 == 0){
          for(int i=20; i<100; i++){
            colorWipe(strip.Color(i,i-20,0),0);
              
          }
          for(int i=100; i>20; i--){
            colorWipe(strip.Color(i,i-20,0),0);
              
          }
          colorWipe(strip.Color(0,0,0),0);
          
          delay(3000);
           
        }
 
      }
            
        
 
          
      
    }
 
 
    void thunder_strike( int type) {
      if(type < 20){
          
            colorWipe_short(0, PIXEL_COUNT, strip.Color(73, 147, 255), 3);
            colorWipe(strip.Color(0, 0, 0), 0);
            delay(500);
            colorWipe_short(0, PIXEL_COUNT, strip.Color(73, 147, 255), 3);
            delay(20);
            colorWipe(strip.Color(0, 0, 0), 0);
            delay(500);
 
      }else if(type < 40){
          
            colorWipe(strip.Color(104, 94, 94), 3);
            colorWipe(strip.Color(0,0,0), 0);
            delay(500);
            colorWipe(strip.Color(104, 94, 94), 3);
            delay(20);
            colorWipe(strip.Color(0,0,0), 0);
            delay(500);
      }else if(type < 60){   
            colorWipe(strip.Color(181, 165, 95), 3);
            delay(1000);
            colorWipe(strip.Color(0,0,0), 0);
            delay(100);
            colorWipe(strip.Color(181, 165, 95), 3);
            delay(500);
            colorWipe(strip.Color(0,0,0), 0);
            delay(500);
      }else{
            rainbowCycle(5);
            colorWipe(strip.Color(0,0,0), 0);
      }
    }
 
 
    void colorWipe_short(uint16_t be, uint16_t en, uint32_t c, uint8_t wait){
      for (uint16_t i = be; i < en; i++) {
        strip.setPixelColor(i, c);
        strip.show();
        delay(wait);
      }
 
    }
 
    // Fill the dots one after the other with a color
    void colorWipe(uint32_t c, uint8_t wait) {
      for (uint16_t i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, c);
        strip.show();
        delay(wait);
      }
    }
 
    void rainbow(uint8_t wait) {
      uint16_t i, j;
 
      for (j = 0; j < 256; j++) {
        for (i = 0; i < strip.numPixels(); i++) {
          strip.setPixelColor(i, Wheel((i + j) & 255));
        }
        strip.show();
        delay(wait);
      }
    }
 
    // Slightly different, this makes the rainbow equally distributed throughout
    void rainbowCycle(uint8_t wait) {
      uint16_t i, j;
 
      for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
        for (i = 0; i < strip.numPixels(); i++) {
          strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
        }
        strip.show();
        delay(wait);
      }
    }
 
     void theaterChase(uint32_t c, uint8_t wait) {
      for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
        for (int q = 0; q < 3; q++) {
          for (int i = 0; i < strip.numPixels(); i = i + 3) {
            strip.setPixelColor(i + q, c);  //turn every third pixel on
          }
          strip.show();
 
          delay(wait);
 
          for (int i = 0; i < strip.numPixels(); i = i + 3) {
            strip.setPixelColor(i + q, 0);      //turn every third pixel off
          }
        }
      }
    }
 
    //Theatre-style crawling lights with rainbow effect
    void theaterChaseRainbow(uint8_t wait) {
      for (int j = 0; j < 256; j++) {   // cycle all 256 colors in the wheel
        for (int q = 0; q < 3; q++) {
          for (int i = 0; i < strip.numPixels(); i = i + 3) {
            strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
          }
          strip.show();
 
          delay(wait);
 
          for (int i = 0; i < strip.numPixels(); i = i + 3) {
            strip.setPixelColor(i + q, 0);      //turn every third pixel off
          }
        }
      }
    }
 
    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos) {
      WheelPos = 255 - WheelPos;
      if (WheelPos < 85) {
        return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
      }
      if (WheelPos < 170) {
        WheelPos -= 85;
        return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
      }
      WheelPos -= 170;
      return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
    }

评论

user-avatar
  • 俺是胡胡

    俺是胡胡2022.07.27

    可以加蓝牙

    1
    • 小含糊online

      小含糊online2022.08.30

      感谢宝贵建议

  • 半行半园

    半行半园2021.01.08

    代码在哪^_^

    0
    • 半行半园

      半行半园2021.01.08

      代码在哪^_^

      1
      • 小含糊online

        小含糊online2021.01.10

        代码已经更新了