尚未链接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源程序如下:
- #include <Adafruit_NeoPixel.h>
- #include "WS2812_Definitions.h"
- #include <avr/pgmspace.h>
- #include <Wire.h>
- #include "Arduino.h"
- #include "PlainProtocol.h"
- #include <Metro.h>
- #include <AudioAnalyzer.h>
- #define PIN 3 //Arduino Pin connect to the LED Strip
- #define LED_COUNT 220 //set the Amount of LED to 180 and this number depend on how many you really have
- PlainProtocol BLUNOPlainProtocol(Serial,115200);//set Serial baud rate to 115200
- Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);// NEO_GRB means the type of your LED Strip
- Metro ledMetro = Metro(18); // Metro for data receive in a regular time
- Analyzer Audio = Analyzer(4,5,0); // Strobe->4 RST->5 Analog->0
- int humid=0;
- int temper=0; // humid and temper means nothing in this program,just for the software in your phone
- int State01=2,State02=0; // the value will change when your press "BUZZER" in your phone
- int Red=10,Green=0,Blue=10,Number_Position_RGB=100;//the value of RGB and the position of the LEDs
- int FreqVal[7];//the spectrum value
- int color[]={0xDC143C,0xFFA500,0xFFFF00, 0x32CD32,0x0000FF,0x2F4F4F,0x4B0082,0xDA70D6};
- int Num_Channel=0,Buff_Channel=0;
- int Num_Color[7],Buff_Num_Color[7];
- boolean Dis_En=false;
- int Num_First_Color=0,Buf_Max=0; //
- int Num_Shark02_High=0,Number_Shark02_LOW=0;
- void setup()
- {
- Audio.Init();//Init module
- leds.begin(); // Call this to start up the LED strip.
- clearLEDs(); // This function, defined below, turns all LEDs off...
- leds.show(); // ...but the LEDs don't actually update until you call this.
- Serial.begin(115200);
- TCCR1B &= ~((1<<CS12)|(1<<CS11)|(1<<CS10)); //Clock select: SYSCLK divde 8;
- TCCR1B |= (1<<CS11);
- TCCR2B &= ~((1<<CS12)|(1<<CS11)|(1<<CS10)); //Clock select: SYSCLK divde 8;
- TCCR2B |= (1<<CS11);
- }
- void loop()
- {
- temper=State01;
- humid=State02;
- if (BLUNOPlainProtocol.available())
- {
- if(BLUNOPlainProtocol.receivedCommand=="TEMP") BLUNOPlainProtocol.write("TEMP", temper);
- else if(BLUNOPlainProtocol.receivedCommand=="HUMID") BLUNOPlainProtocol.write("HUMID", humid);
- if (BLUNOPlainProtocol.receivedCommand=="BUZZER") //get command of "BUZZER"
- {
- if(BLUNOPlainProtocol.receivedContent[0]==1) State01=1;
- else State01=2;
- }
- else if(BLUNOPlainProtocol.receivedCommand=="RGBLED") //get command of "RGB"
- {
- State01=3;
- Red = BLUNOPlainProtocol.receivedContent[0];
- Green= BLUNOPlainProtocol.receivedContent[1];
- Blue = BLUNOPlainProtocol.receivedContent[2];
- }
- }
- if (ledMetro.check() == 1)//time for metro
- {
- if(State01==1)
- {
- clearLEDs(); // Turn off all LEDs
- leds.show();
- }
- else if(State01==2)
- {
- Rock_With_Song();//leds.show();
- }
- else if(State01==3)
- {
- for (int i=0;i<LED_COUNT;i++)
- {
- if(i%7==0)
- leds.setPixelColor(i,Red, Green, 0);//change the color
- else if(i%3==0)
- leds.setPixelColor(i,0, Green, Blue);//change the color
- else if(i%2==0)
- leds.setPixelColor(i,Red, Green, Blue);//change the color
- else
- leds.setPixelColor(i,Red,0, Blue);//change the color
- }
- leds.show();
- }
- }
- }
- void clearLEDs()
- {
- for (int i=0; i<LED_COUNT; i++) leds.setPixelColor(i, 0);
- }
- void rainbow(byte startPosition)
- {
- int rainbowScale = 192/LED_COUNT;
- leds.setPixelColor( startPosition, rainbowOrder((rainbowScale * ( startPosition + startPosition)) % 192));
- leds.show();
- }
- uint32_t rainbowOrder(byte position)
- {
- if (position < 31) // Red -> Yellow (Red = FF, blue = 0, green goes 00-FF)
- {
- return leds.Color(0xFF, position * 8, 0);
- }
- else if (position < 63) // Yellow -> Green (Green = FF, blue = 0, red goes FF->00)
- {
- position -= 31;
- return leds.Color(0xFF - position * 8, 0xFF, 0);
- }
- else if (position < 95) // Green->Aqua (Green = FF, red = 0, blue goes 00->FF)
- {
- position -= 63;
- return leds.Color(0, 0xFF, position * 8);
- }
- else if (position < 127) // Aqua->Blue (Blue = FF, red = 0, green goes FF->00)
- {
- position -= 95;
- return leds.Color(0, 0xFF - position * 8, 0xFF);
- }
- else if (position < 159) // Blue->Fuchsia (Blue = FF, green = 0, red goes 00->FF)
- {
- position -= 127;
- return leds.Color(position * 8, 0, 0xFF);
- }
- else //160 <position< 191 Fuchsia->Red (Red = FF, green = 0, blue goes FF->00)
- {
- position -= 159;
- return leds.Color(0xFF, 0x00, 0xFF - position * 8);
- }
- }
- void Rock_With_Song()
- {
- Buff_Channel=Num_Channel;// Buff_Channnel can store the number of the channel which has the max spectrum value
- Audio.ReadFreq(FreqVal);// get the spectrum value
- for (int i=0;i<6;i++)
- {
- if(FreqVal[Num_Channel]<FreqVal[i]) Num_Channel=i;// get the number of the channel which has the max spectrum value
- Buff_Num_Color[i]=Num_Color[i]; //store the value for the using below
- }
- if(FreqVal[Num_Channel]<400) {
- Number_Shark02_LOW++;
- } //count if a low voice started
- if(Buf_Max!=Num_Channel && FreqVal[Num_Channel]>300) // judge if the sound changed
- {
- Num_First_Color++;
- Dis_En=true; //enable the display
- if(FreqVal[Num_Channel]>400) Number_Shark02_LOW=0; //reset the count of low voice
- if (Num_First_Color==7) Num_First_Color=0; //for recycle
- for(int i=0;i<7;i++) //recycle the colour
- {
- int x=random(0,6);
- if(i==0) Num_Color[i]=Num_First_Color; //recycle the value
- else Num_Color[i]=Buff_Num_Color[x]; //change the color randomly
- }
- }
- Buf_Max=Num_Channel; //store the max_value_channel for next use
- if( (Buf_Max==5 || Buf_Max==4 ) && FreqVal[Buf_Max]>700) //count when the High vlaue of the sound started
- {
- Num_Shark02_High++;
- }
- else Num_Shark02_High=0; //reset the count of the High_value_count
- if(Num_Shark02_High>22) //time of High value voice reached
- {
- for(int i=0;i<LED_COUNT/2;i++) //these are effects of color changing
- {
- leds.setPixelColor(i,rainbowOrder(i)); //rising from two origin points
- leds.setPixelColor(i+LED_COUNT/2,rainbowOrder(i));
- leds.show();
- if(i>LED_COUNT/4) delay(1);
- }
- for(int i=0;i<LED_COUNT/2;i++)
- {
- leds.setPixelColor(LED_COUNT-i,rainbowOrder(i));
- leds.setPixelColor(i+LED_COUNT/2,rainbowOrder(i));
- leds.show();
- }
- for (int i=0;i<LED_COUNT;i++)
- {
- leds.setPixelColor(i,GOLD);
- }
- leds.show();
- Audio.ReadFreq(FreqVal);
- if(FreqVal[4]>800) //if High sound value continues, take another effect out!
- {
- for(int x=0;x<6;x++)
- {
- if(FreqVal[x]>1000)
- {
- for(int y=0;y<LED_COUNT/2;y++) {
- leds.setPixelColor(LED_COUNT-y,RED);
- leds.setPixelColor(LED_COUNT/2-y,RED);
- leds.show();
- }
- x=7;
- }
- }
- }
- Num_Shark02_High=0; //reset the count when effect playing finished
- }
- if(Number_Shark02_LOW>40) //when the time of low value sound reached
- {
- for(int i=0;i<LED_COUNT/2;i++) //close the light from two point
- {
- leds.setPixelColor(i,0);
- leds.setPixelColor(LED_COUNT-i,0);
- leds.show();
- }
- Number_Shark02_LOW=0;
- Dis_En=false; //disable the function:Display() because the light should be closed
- }
- if(Dis_En==true)
- Display();
- }
- void Display()
- {
- for (int i=0;i<LED_COUNT;i++)
- {
- if(i<LED_COUNT/7)
- {
- leds.setPixelColor(i,color[Num_Color[0]]);
- }
- else if(i<(LED_COUNT/7)*2) {
- leds.setPixelColor(i,color[Num_Color[1]]);
- }
- else if(i<(LED_COUNT/7)*3) {
- leds.setPixelColor(i,color[Num_Color[2]]);
- }
- else if(i<(LED_COUNT/7)*4) {
- leds.setPixelColor(i,color[Num_Color[3]]);
- }
- else if(i<(LED_COUNT/7)*5) {
- leds.setPixelColor(i,color[Num_Color[4]]);
- }
- else if(i<(LED_COUNT/7)*6) {
- leds.setPixelColor(i,color[Num_Color[5]]);
- }
- else if(i<LED_COUNT) {
- leds.setPixelColor(i,color[Num_Color[6]]);
- }
- }
- leds.show();
- }
复制代码
蘑菇外形小灯创意DIY所有相关资源资料51hei提供下载:
蘑菇灯.zip
(6.88 MB, 下载次数: 40)
|