找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9032|回复: 5
收起左侧

蘑菇外形小灯创意DIY Arduino源码+APP+制作说明

[复制链接]
ID:230901 发表于 2017-9-7 17:17 | 显示全部楼层 |阅读模式
尚未链接bluno进行测试,在UNO上测试的效果初步完成

详细制作说明:
一款智能灯 是注重外形 的设计还是 操作上体 验呢?而智 能蘑菇灯给 出的答案是 两者兼具 才 更爽快!特有的无线充电功能让它可以更方便的进行充电,萌萌的蘑菇机身使用 3DPLA 材 料打印出来,搭载体积小巧的 Bluno Beetle 控制器使它可以用手机 APP 来控制,此外!它的 外形小巧精 致可携带也 许是世界上 最小的可携带智能灯 了,相信制 作这样一个 酷炫的蘑 菇 灯,是送给自己心仪女孩子最好的礼物~~话不多说,先看照片!








看到照片作为爱动手的你是不是早已饥渴难耐了呢,什么!你说光看照片不过瘾?要看教程! 好吧,那就跟我来一起看看这盏酷炫的蘑菇灯是怎样制作出来的哈哈~~~
首 先 准 备需要的材料






Bluno Beetle 控制器              3D 打印机(打印蘑菇灯) 无线充电模块 5V/1A              磁环
RGBLED 模块 220 欧电阻 电池 3.7V       发光二极管 自锁开关       充电插口
强磁铁              焊接导线 制作步骤
第一步 蘑菇灯本体制作。
1、将电池与接受线圈并联焊接,并套上热缩管绝缘。




2、焊接自锁开关引线,焊接 RGB 模块引线(红色线焊接 VCC,蓝色线焊接 GND,绿色线焊 接 DIN),电池电源正极和 Bluno Beetle 控制器的正极经自锁开关串联焊接,RGB 模块绿色引
线接 Bluno Beetle 控制器数字口 3 引脚,上传程序到 Bluno Beetle 板然后通电测试电路是否 正常。(程序源码和需要的库文件已经上传至文章结尾,需要请自行下载。)









3、安装控制电路部分,无线充电过程中线圈会发热,这里用哥俩好胶水固定接收线圈, 同 时加入强磁铁能更好的与充电发射线圈底座重合定位,考虑到充电过程中如果要控制灯光 , Bluno Beetle 的蓝牙信号可能会受到无线充电线圈的电磁干扰,加入不锈钢铁片屏蔽电磁干 扰。







4、待无线接收线圈固定好后,依次放入自锁开关、电池、Bluno Beetle 控制板、RGB 模块、 并用热熔胶将其固定粘接牢固。









5、用热熔胶将蘑菇灯帽和蘑菇灯柱粘接起来,挤出的胶要均匀涂抹,动作干净利落。























第二步              无线充电底座制作
1、将打印好的底座中框和上盖组装好,并用热熔胶加固。


2、焊接充电插口与引线,将充电插口安装在中框充电接口预留处,用热熔胶固定。





3、在发光二极管的负极接上一个 220 欧的电子,并将二极管正负极与充电接口正负极并联, 焊接正极时可以用热缩管绝缘。




4、将无线充电发射线圈装入,并用热熔胶粘合,在发射线圈的中心点粘上强磁铁,作用 是 与蘑菇灯充电时起到定位作用。



5、加入防干扰磁环,将输入电源线穿入磁环缠绕两圈,并将输入线正负极与发射模块正 负 极焊接,测量电压是否正常后用热熔胶固定。





6、准备好螺丝、旋具将充电底座下盖安装上,通电测试正常。





最后在手机上安装 BLUNO APP 控制软件,项目就算制作完成了。毫无疑问,制作这样 的智能灯简单易上手,赶紧造起来吧!一起分享造物的快乐,最后再来看看智能蘑菇灯的更 多照片~~



arduino源程序如下:

  1. #include <Adafruit_NeoPixel.h>
  2. #include "WS2812_Definitions.h"
  3. #include <avr/pgmspace.h>
  4. #include <Wire.h>
  5. #include "Arduino.h"
  6. #include "PlainProtocol.h"
  7. #include <Metro.h>
  8. #include <AudioAnalyzer.h>

  9. #define PIN 3             //Arduino Pin connect to the LED Strip
  10. #define LED_COUNT 220      //set the Amount of LED to 180 and this number depend on how many you really have

  11. PlainProtocol BLUNOPlainProtocol(Serial,115200);//set Serial baud rate to 115200   
  12. Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);// NEO_GRB means the type of your LED Strip
  13. Metro ledMetro = Metro(18);  // Metro for data receive in a regular time
  14. Analyzer Audio = Analyzer(4,5,0); // Strobe->4 RST->5 Analog->0

  15. int humid=0;
  16. int temper=0;          //  humid and temper means nothing in this program,just for the software in your phone
  17. int State01=2,State02=0;         //  the value will change when your press "BUZZER" in your phone   
  18. int Red=10,Green=0,Blue=10,Number_Position_RGB=100;//the value of RGB and the position of the LEDs
  19. int FreqVal[7];//the spectrum value
  20. int color[]={0xDC143C,0xFFA500,0xFFFF00, 0x32CD32,0x0000FF,0x2F4F4F,0x4B0082,0xDA70D6};

  21. int Num_Channel=0,Buff_Channel=0;
  22. int Num_Color[7],Buff_Num_Color[7];
  23. boolean Dis_En=false;
  24. int Num_First_Color=0,Buf_Max=0; //
  25. int Num_Shark02_High=0,Number_Shark02_LOW=0;

  26. void setup()
  27. {
  28.   Audio.Init();//Init module
  29.   leds.begin();  // Call this to start up the LED strip.
  30.   clearLEDs();   // This function, defined below, turns all LEDs off...
  31.   leds.show();   // ...but the LEDs don't actually update until you call this.
  32.   Serial.begin(115200);
  33.   TCCR1B &= ~((1<<CS12)|(1<<CS11)|(1<<CS10));        //Clock select: SYSCLK divde 8;
  34.   TCCR1B |= (1<<CS11);
  35.   TCCR2B &= ~((1<<CS12)|(1<<CS11)|(1<<CS10));        //Clock select: SYSCLK divde 8;
  36.   TCCR2B |= (1<<CS11);
  37. }

  38. void loop()
  39. {
  40.   temper=State01;
  41.   humid=State02;
  42.   if (BLUNOPlainProtocol.available())
  43.   {
  44.     if(BLUNOPlainProtocol.receivedCommand=="TEMP")          BLUNOPlainProtocol.write("TEMP", temper);  
  45.     else if(BLUNOPlainProtocol.receivedCommand=="HUMID")    BLUNOPlainProtocol.write("HUMID", humid);

  46.     if (BLUNOPlainProtocol.receivedCommand=="BUZZER")          //get command of "BUZZER"
  47.     {
  48.       if(BLUNOPlainProtocol.receivedContent[0]==1)  State01=1;
  49.       else                                          State01=2;
  50.     }
  51.     else if(BLUNOPlainProtocol.receivedCommand=="RGBLED")  //get command of  "RGB"
  52.     {
  53.       State01=3;
  54.       Red  = BLUNOPlainProtocol.receivedContent[0];
  55.       Green= BLUNOPlainProtocol.receivedContent[1];
  56.       Blue = BLUNOPlainProtocol.receivedContent[2];
  57.     }
  58.   }

  59.   if (ledMetro.check() == 1)//time for metro
  60.   {
  61.     if(State01==1)
  62.     {
  63.       clearLEDs();  // Turn off all LEDs
  64.       leds.show();
  65.     }
  66.     else if(State01==2)     
  67.     {   
  68.         Rock_With_Song();//leds.show();           
  69.     }
  70.     else if(State01==3)
  71.     {
  72.       for (int i=0;i<LED_COUNT;i++)
  73.       {
  74.         if(i%7==0)
  75.           leds.setPixelColor(i,Red, Green, 0);//change the color
  76.         else if(i%3==0)
  77.           leds.setPixelColor(i,0, Green, Blue);//change the color
  78.         else if(i%2==0)
  79.           leds.setPixelColor(i,Red, Green, Blue);//change the color
  80.         else     
  81.           leds.setPixelColor(i,Red,0, Blue);//change the color
  82.       }
  83.       leds.show();
  84.     }
  85.   }
  86. }


  87. void clearLEDs()
  88. {
  89.   for (int i=0; i<LED_COUNT; i++)  leds.setPixelColor(i, 0);
  90. }

  91. void rainbow(byte startPosition)
  92. {
  93.   int rainbowScale =  192/LED_COUNT;
  94.   leds.setPixelColor( startPosition, rainbowOrder((rainbowScale * ( startPosition + startPosition)) % 192));
  95.   leds.show();
  96. }
  97. uint32_t rainbowOrder(byte position)
  98. {
  99.   if (position < 31)  // Red -> Yellow (Red = FF, blue = 0, green goes 00-FF)
  100.   {
  101.     return leds.Color(0xFF, position * 8, 0);
  102.   }
  103.   else if (position < 63)  // Yellow -> Green (Green = FF, blue = 0, red goes FF->00)
  104.   {
  105.     position -= 31;
  106.     return leds.Color(0xFF - position * 8, 0xFF, 0);
  107.   }
  108.   else if (position < 95)  // Green->Aqua (Green = FF, red = 0, blue goes 00->FF)
  109.   {
  110.     position -= 63;
  111.     return leds.Color(0, 0xFF, position * 8);
  112.   }
  113.   else if (position < 127)  // Aqua->Blue (Blue = FF, red = 0, green goes FF->00)
  114.   {
  115.     position -= 95;
  116.     return leds.Color(0, 0xFF - position * 8, 0xFF);
  117.   }
  118.   else if (position < 159)  // Blue->Fuchsia (Blue = FF, green = 0, red goes 00->FF)
  119.   {
  120.     position -= 127;
  121.     return leds.Color(position * 8, 0, 0xFF);
  122.   }
  123.   else  //160 <position< 191   Fuchsia->Red (Red = FF, green = 0, blue goes FF->00)
  124.   {
  125.     position -= 159;
  126.     return leds.Color(0xFF, 0x00, 0xFF - position * 8);
  127.   }
  128. }


  129. void Rock_With_Song()
  130. {
  131.   Buff_Channel=Num_Channel;// Buff_Channnel can store the number of the channel which has the max spectrum value
  132.   Audio.ReadFreq(FreqVal);// get the spectrum value
  133.   for (int i=0;i<6;i++)
  134.   {
  135.     if(FreqVal[Num_Channel]<FreqVal[i])  Num_Channel=i;// get the number of the channel which has the max spectrum value
  136.     Buff_Num_Color[i]=Num_Color[i];                      //store the value for the using below
  137.   }
  138.   if(FreqVal[Num_Channel]<400)      {  
  139.     Number_Shark02_LOW++;
  140.   } //count if a low voice started
  141.   if(Buf_Max!=Num_Channel && FreqVal[Num_Channel]>300)    // judge if the sound changed
  142.   {
  143.     Num_First_Color++;
  144.     Dis_En=true;                                          //enable the display
  145.     if(FreqVal[Num_Channel]>400) Number_Shark02_LOW=0;    //reset the count of low voice
  146.     if (Num_First_Color==7) Num_First_Color=0;                              //for recycle
  147.     for(int i=0;i<7;i++)                                  //recycle the colour
  148.     {
  149.       int x=random(0,6);         
  150.       if(i==0)   Num_Color[i]=Num_First_Color;                  //recycle the value        
  151.       else       Num_Color[i]=Buff_Num_Color[x];       //change the color randomly
  152.     }
  153.   }

  154.   Buf_Max=Num_Channel;                                   //store the max_value_channel for next use

  155.   if( (Buf_Max==5 || Buf_Max==4 ) && FreqVal[Buf_Max]>700)  //count when the  High vlaue of the sound started
  156.   {
  157.     Num_Shark02_High++;
  158.   }
  159.   else Num_Shark02_High=0;                                  //reset the count of the High_value_count

  160.   if(Num_Shark02_High>22)                                  //time of High value voice reached
  161.   {
  162.     for(int i=0;i<LED_COUNT/2;i++)                         //these are effects of color changing
  163.     {
  164.       leds.setPixelColor(i,rainbowOrder(i));               //rising from two origin points
  165.       leds.setPixelColor(i+LED_COUNT/2,rainbowOrder(i));
  166.       leds.show();
  167.       if(i>LED_COUNT/4) delay(1);
  168.     }
  169.     for(int i=0;i<LED_COUNT/2;i++)                        
  170.     {
  171.       leds.setPixelColor(LED_COUNT-i,rainbowOrder(i));
  172.       leds.setPixelColor(i+LED_COUNT/2,rainbowOrder(i));
  173.       leds.show();
  174.     }
  175.     for (int i=0;i<LED_COUNT;i++)
  176.     {
  177.       leds.setPixelColor(i,GOLD);
  178.     }
  179.     leds.show();
  180.     Audio.ReadFreq(FreqVal);                                 
  181.     if(FreqVal[4]>800)                                         //if High sound value continues, take another effect out!
  182.     {
  183.       for(int x=0;x<6;x++)
  184.       {
  185.         if(FreqVal[x]>1000)   
  186.         {
  187.           for(int y=0;y<LED_COUNT/2;y++)    {
  188.             leds.setPixelColor(LED_COUNT-y,RED);
  189.             leds.setPixelColor(LED_COUNT/2-y,RED);
  190.             leds.show();
  191.           }
  192.           x=7;
  193.         }
  194.       }
  195.     }
  196.     Num_Shark02_High=0;                                  //reset the count when effect playing finished
  197.   }
  198.   if(Number_Shark02_LOW>40)                             //when the time of low value sound reached
  199.   {
  200.     for(int i=0;i<LED_COUNT/2;i++)                       //close the light from two point
  201.     {
  202.       leds.setPixelColor(i,0);
  203.       leds.setPixelColor(LED_COUNT-i,0);
  204.       leds.show();
  205.     }
  206.     Number_Shark02_LOW=0;
  207.     Dis_En=false;                                    //disable the function:Display() because the light should be closed
  208.   }
  209.   if(Dis_En==true)
  210.     Display();
  211. }

  212. void Display()                           
  213. {
  214.   for (int i=0;i<LED_COUNT;i++)
  215.   {
  216.     if(i<LED_COUNT/7)
  217.     {
  218.       leds.setPixelColor(i,color[Num_Color[0]]);  
  219.     }
  220.     else if(i<(LED_COUNT/7)*2)   {  
  221.       leds.setPixelColor(i,color[Num_Color[1]]);  
  222.     }
  223.     else if(i<(LED_COUNT/7)*3)   {  
  224.       leds.setPixelColor(i,color[Num_Color[2]]);  
  225.     }
  226.     else if(i<(LED_COUNT/7)*4)   {  
  227.       leds.setPixelColor(i,color[Num_Color[3]]);  
  228.     }
  229.     else if(i<(LED_COUNT/7)*5)   {  
  230.       leds.setPixelColor(i,color[Num_Color[4]]);  
  231.     }
  232.     else if(i<(LED_COUNT/7)*6)   {  
  233.       leds.setPixelColor(i,color[Num_Color[5]]);  
  234.     }
  235.     else if(i<LED_COUNT)         {  
  236.       leds.setPixelColor(i,color[Num_Color[6]]);  
  237.     }
  238.   }
  239.   leds.show();
  240. }


复制代码

0.png

蘑菇外形小灯创意DIY所有相关资源资料51hei提供下载:
蘑菇灯.zip (6.88 MB, 下载次数: 40)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:231310 发表于 2017-9-8 14:43 | 显示全部楼层
厉害了
回复

使用道具 举报

ID:266081 发表于 2017-12-24 19:04 | 显示全部楼层
好资料,51黑有你更精彩!!!
回复

使用道具 举报

ID:348109 发表于 2018-6-9 23:06 来自手机 | 显示全部楼层
厉害了
回复

使用道具 举报

ID:356463 发表于 2018-6-29 22:08 | 显示全部楼层
你好,请问你用这个app的时候有没有连接上设备有跳出这个页面,里面都是设备的信息,但是后退又断开连接了? 140551caes8ta1epezgkev.jpg
回复

使用道具 举报

ID:396751 发表于 2020-5-22 11:53 | 显示全部楼层
51黑总是能带来很多惊喜,感谢楼主
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表