Arduino魔幻音乐盒-Arduino中文社区 - Powered by Discuz! Archiver

MicroMaker 发表于 2016-12-18 11:12

Arduino魔幻音乐盒

本帖最后由 MicroMaker 于 2017-5-14 09:32 编辑

       这个盒子可以不用按按钮就可以发出美妙的音乐。只要将手放在盒子上上下摆舞几下,你的耳朵里就会响起优美的音符,随着优美的音符响起,发出迷幻的光线,好像一个看不到底的时空隧道。                                                          它的原理是:打开开关,将手放置于超声波传感器上方,如果探测到在一个范围内,喇叭就发出一个音调;探测到在另一个范围内,喇叭就会发出另一个音调。同时,不同的LED发出不同的色彩。光线在镜子与单透膜之间无限反射,形成无数个影子。
整个小制作,分成五个部分:第一部分:先用超声波传感器测量超声波碰到手再返回的时间。第二部分:由主芯片发出不同频率的脉冲,使喇叭发出各种各样的音调。音符(共11个):a3;b3;c4;d4;e4;f4;g4;a4;b4;c5;d5;第三部分:利用不同的RGB颜色配比,形成由30个LED组成的光带,用一面镜子做底板,单透膜作为面板,LED光带放在镜子和单透膜之间,光线在镜子和单透膜之间无限反射,形成许多光带的影子。第四部分:Arduino主芯片收到信息后,用公式计算出手与传感器之间的距离(公式:距离=时间*音速(340米/秒)/2)。按照不同的距离,主芯片命令发出不同的音乐、不同的LED发出不同的光。比如:距离为130mm,喇叭发出la(c),第1、2、3、27、28、29号LED点亮。   第五部分:开发系统、开发板    本小制作采用了Arduino UNO开发板    主控芯片:ATMEGA 328p    编程软件为Arduino IDE    编程语言:C/C++
主要元件目录表:1.Arduino uno主板(1块)2.us-100超声波模块(1块)3.喇叭(1只)4.30个LED组成的光环(1条)5.11.1V电池组(1块)6.电源降压模块(1块)7.发光按钮开关(1个)8.镜子(1面)9.有机玻璃外壳(外贴单透膜)
             超声波传感器               Arduino Uno单片机                      喇叭                      LED光带、镜子                  单透膜                  有机玻璃外壳   组装过程:       组装(1)                         组装(2)
      组装(3)                        组装(4)          我去年用这个作品还获得过绍兴市第二季校园科学达人的称号呢!作品程序:#include <Adafruit_NeoPixel.h>   //彩色LED库
# define PIN 6   //设置LED端口
# define MAX_LED 30    //特定的程序,最后一个数字是LED光带中LED的数量
Adafruit_NeoPixel strip = Adafruit_NeoPixel( MAX_LED, PIN, NEO_RGB + NEO_KHZ800 );//彩色LED库的内部设置
int a = 2;// 将Arduino 的Pin2 连接至US-100 的Echo/RX
int b = 3;// 将Arduino 的Pin3 连接至US-100 的Trig/TX
void setup() {
pinMode(a,INPUT);// 设置a 为输入模式。
pinMode(b,OUTPUT);// 设置b 为输出模式。
strip.begin();   //启动LED函数库
strip.show();   //将所有的LED灯灭掉
}
void loop() {
long c = 0;//脉冲时间
long d = 0;//脉冲距离
// 通过Trig/Pin 发送脉冲,触发US-100 测距
digitalWrite(b,LOW); // 先拉低,以确保脉冲识别正确
delayMicroseconds(2);// 等待2us
digitalWrite(b,HIGH);// 开始通过Trig/Pin 发送脉冲
delayMicroseconds(12);// 设置脉冲宽度为12us (>10us)
digitalWrite(b,LOW);// 结束脉冲
c = pulseIn(a,HIGH);// 计算US-100 返回的脉冲时间
d = c*0.34/2; //距离=脉冲时间*声波的速度(340/s)/2
if(d>50&&d<=150)   //当脉冲距离>50mm并且<=150的时候,执行以下程序   
{
ala();//喇叭发出a3的音调   
ledz();   //使所有LED灯灭
leda();    //使1.2.3.27.28.29盏LED灯亮
}
if(d>150&&d<=200)
{
asi();
ledz();
ledb();
}
if(d>200&&d<=250)
{
bdo();
ledz();
ledc();
}
if(d>250&&d<=300)
{
bre();
ledz();
ledd();
}
if(d>300&&d<=350)
{
bmi();
ledz();
lede();
}
if(d>350&&d<=400)
{
bfa();
ledz();
ledf();
}
if(d>400&&d<=450)
{
bso();
ledz();
ledg();
}
if(d>450&&d<=500)
{
bla();
ledz();
ledh();
}
if(d>500&&d<=550)
{
bsi();
ledz();
ledi();
}
if(d>550&&d<=600)
{
cdo();
ledz();
ledj();
}
if(d>600&&d<=800)
{
cre();
ledz();
ledk();
}
if(d<=50)
{
noTone(9);
ledz();
ledy();
}
if(d>800)
{
noTone(9);
ledz();
ledy();
}
delay(400);// 每秒测量2.5次
}
void ala()//设置一个函数:以后想要使用{ }里的程序的话,可以直接打函数名,如:ala               
{
tone(9,440);    //声音函数(LED端口,频率).发出a3的音调
}
void asi()
{
tone(9,493);   //发出b3的音调
}
void bdo()
{
tone(9,523);   //发出c4的音调
}
void bre()
{
tone(9,587);   //发出d4的音调
}
void bmi()
{
tone(9,659);   //发出e4的音调
}
void bfa()
{
tone(9,698);   //发出f4的音调
}
void bso()
{
tone(9,784);   //发出g4的音调
}
void bla()
{
tone(9,880);   //发出a4的音调
}
void bsi()
{
tone(9,988);    //发出b4的音调
}
void cdo()
{
tone(9,1046);    //发出c5的音调
}
void cre()
{
tone(9,1175);    //发出d5的音调
}
void ledj()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small yellow
uint32_t r = strip.Color(25,25,0);    //small small yellow
//设置LED发出的颜色
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(7, f);
strip.setPixelColor(8, g);   
strip.setPixelColor(9, h);   
strip.setPixelColor(10, i);      
strip.setPixelColor(11, j);   
strip.setPixelColor(18, j);   
strip.setPixelColor(19, i);
strip.setPixelColor(20, h);   
strip.setPixelColor(21, g);   
strip.setPixelColor(22, f);      
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o );      
strip.show();
}
void ledi()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(7, f);
strip.setPixelColor(8, g);   
strip.setPixelColor(9, h);   
strip.setPixelColor(10, i);      
strip.setPixelColor(19, i);
strip.setPixelColor(20, h);   
strip.setPixelColor(21, g);   
strip.setPixelColor(22, f);      
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledh()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(7, f);
strip.setPixelColor(8, g);   
strip.setPixelColor(9, h);   
strip.setPixelColor(20, h);   
strip.setPixelColor(21, g);   
strip.setPixelColor(22, f);      
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledg()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(7, f);
strip.setPixelColor(8, g);      
strip.setPixelColor(21, g);   
strip.setPixelColor(22, f);      
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledf()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(7, f);
strip.setPixelColor(22, f);      
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void lede()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledd()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledc()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);      
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
strip.show();
}
void ledb()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void leda()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledk()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(29, p);
strip.setPixelColor(0, p);   
strip.setPixelColor(1, o);
strip.setPixelColor(2, a);   
strip.setPixelColor(3, b);   
strip.setPixelColor(4, m);   
strip.setPixelColor(5, n);
strip.setPixelColor(6, e);   
strip.setPixelColor(7, f);
strip.setPixelColor(8, g);   
strip.setPixelColor(9, h);   
strip.setPixelColor(10, i);      
strip.setPixelColor(11, j);
strip.setPixelColor(12, k);   
strip.setPixelColor(13, q);
strip.setPixelColor(14, r);   
strip.setPixelColor(15, r);   
strip.setPixelColor(16, q);      
strip.setPixelColor(17, k);
strip.setPixelColor(18, j);   
strip.setPixelColor(19, i);
strip.setPixelColor(20, h);   
strip.setPixelColor(21, g);   
strip.setPixelColor(22, f);      
strip.setPixelColor(23, e);
strip.setPixelColor(24, n);   
strip.setPixelColor(25, m);
strip.setPixelColor(26, b);   
strip.setPixelColor(27, a);   
strip.setPixelColor(28, o);      
strip.show();
}
void ledy()
{
//颜色变量设置:
uint32_t a = strip.Color(191,0,255);      //blue
uint32_t b = strip.Color(112,218,214);      //small purple         
uint32_t m = strip.Color(0,120,0);      //red
uint32_t n = strip.Color(69,255,0);      //orange
uint32_t e = strip.Color(255,255,0);      //yellow
uint32_t f = strip.Color(139,34,34);      //green
uint32_t g = strip.Color(255,0,255);      //green or blue
uint32_t h = strip.Color(0,0,255);      //blue
uint32_t i = strip.Color(0,128,128);      //purple
uint32_t j = strip.Color(0,255,0);      //big red
uint32_t k = strip.Color(165,255,0);      //big orange
uint32_t o = strip.Color(111,0,175);      //small blue
uint32_t p = strip.Color(31,0,95);    //small small blue
uint32_t q = strip.Color(85,85,0);      //small blue
uint32_t r = strip.Color(25,25,0);    //small small blue
strip.setPixelColor(0, p);
strip.setPixelColor(1, o);   
strip.setPixelColor(28, o);      
strip.setPixelColor(29, p);      
strip.show();
}
void ledz()
{
//颜色变量设置:
uint32_t u = strip.Color(0,0,0);    //black
strip.setPixelColor(0, u);
strip.setPixelColor(1, u);   
strip.setPixelColor(2, u);
strip.setPixelColor(3, u);   
strip.setPixelColor(4, u);   
strip.setPixelColor(5, u);   
strip.setPixelColor(6, u);
strip.setPixelColor(7, u);   
strip.setPixelColor(8, u);
strip.setPixelColor(9, u);   
strip.setPixelColor(10, u);   
strip.setPixelColor(11, u);      
strip.setPixelColor(12, u);
strip.setPixelColor(13, u);   
strip.setPixelColor(14, u);
strip.setPixelColor(15, u);   
strip.setPixelColor(16, u);   
strip.setPixelColor(17, u);      
strip.setPixelColor(18, u);
strip.setPixelColor(19, u);   
strip.setPixelColor(20, u);
strip.setPixelColor(21, u);   
strip.setPixelColor(22, u);   
strip.setPixelColor(23, u);      
strip.setPixelColor(24, u);
strip.setPixelColor(25, u);   
strip.setPixelColor(26, u);
strip.setPixelColor(27, u);   
strip.setPixelColor(28, u);   
strip.setPixelColor(29, u);      
}
/*
距离计算公式:
声波的速度=1秒340米
1秒=1000000微秒
1微秒=0.000001秒
1微秒声波的距离=340米*0.000001秒=0.00034米
c微秒声波的距离=c*0.00034米
1米=1000毫米
c微秒声波的距离=c*0.34毫米
声波往返1次
实际距离=c*0.34毫米/2
*/




电磁波 发表于 2016-12-18 11:23

做的真不错。

jackten 发表于 2016-12-18 13:16

顶                                    

单片机菜鸟 发表于 2016-12-18 18:17

楼主做得可以额赞

吹口琴的钢铁侠 发表于 2016-12-18 21:41

绍兴离我家挺近的,后生可畏啊

markmarkmark 发表于 2016-12-19 15:27

后生可畏啊

KennyMcCormick 发表于 2016-12-30 22:35

想问一下楼主有机玻璃外壳和30个led在哪里买(新人刚开始接触)

邪门的wenqing 发表于 2017-1-6 15:05

赞!正邦

MicroMaker 发表于 2017-1-6 19:23

KennyMcCormick 发表于 2016-12-30 22:35
想问一下楼主有机玻璃外壳和30个led在哪里买(新人刚开始接触)

qq:
1632466445
or
741587258

MicroMaker 发表于 2017-1-7 12:01

KennyMcCormick 发表于 2016-12-30 22:35
想问一下楼主有机玻璃外壳和30个led在哪里买(新人刚开始接触)

有机玻璃外壳是网上定做的;
LED:
http://c.b0wr.com/h.Xk9gn7?cv=Q6146NaiM&sm=6cdd14
页: [1] 2 3
查看完整版本: Arduino魔幻音乐盒