“Rhythm Lamp”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
(Created page with "{{Language| Rhythm Lantern}} {| style="width: 800px;" |- | ==Purpose== To control the color of a lantern by detecting sound via mic sound detection sensor. ==Principle== ==...")
 
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
{{Language| Rhythm Lantern}}
+
{{Language| Rhythm Lamp}}
 
{| style="width: 800px;"
 
{| style="width: 800px;"
 
|-
 
|-
 
|
 
|
==Purpose==
+
==Objective==
To control the color of a lantern by detecting sound via mic sound detection sensor.  
+
Speak toward MIC, the lamp will change along with the sound rhythm.
 +
[[File:mic_sound.jpg|600px|center]]
  
==Principle==
+
==principle==
 +
*MIC sensor introduction
 +
MIC sensor can turn sound signal to electricity signal.
 +
It can detect sound volume but can't detect certain sound.
 +
*Rhythm Lamp
 +
Detect sound volume via MIC sensor and the system will judge which color range the sound belongs to. At the same, comparing with the pre-set trigger value and choosing to open or close light change, therefore, to control color change of the lamp.
 +
 
 +
[[File:mic_sch.jpg|600px|center|thumb]]
  
 
==Equipment==
 
==Equipment==
 
{|class="wikitable"
 
{|class="wikitable"
 
|-
 
|-
|Module||Number||Function
+
|Moudle||Number||Function  
|-
 
|[[Microduino-CoreUSB]]||1||Core board 
 
 
|-
 
|-
|[[Microduino-Sensorhub]]||1||Sensor transfer board  
+
|[[mCookie-CoreUSB]]||1||Core board
 
|-
 
|-
|[[Microduino-Sound/zh]]||1||Sound detection sensor
+
|[[mCookie-Hub]]||1||Sensor pin board
 
|-
 
|-
|[[Microduino-Lantern]]||1||Colored light
+
|[[Microduino-Sound]]||1||Sound detection sensor
 
|-
 
|-
|[[Microduino-BM]]||1||Battery management 
+
| [[Microduino-Color led]]||1||Colored LED light
 
|}
 
|}
 +
[[File:mic _lamp.jpg|600px|center]]
  
 +
==Preparation==
 +
*Setup 1:Connect CoreUSB and PC/Mac with USB cable and open Arduino IDE.
 +
[[File:CoreUSB_Ble_pc.jpg|600px|center]]
 +
*Setup 2:Download program:[https://github.com/Microduino/Microduino_Tutorials/blob/master/MCookie_Tutorial/SHENGRI/SHENGRI.ino SHENGRI]
 +
[[File: _SHENGR.jpg|600px|center]]
  
  [[File:mic _lamp.jpg|600px|center|thumb]]
+
* Setup 3:Load code, copy program to IDE. Select the right boardcard and COM port and then download after passing the compiling.  
 
+
==Program Description==
==Hardware Buildup==
+
*Read sound analog value (A0 pin), which can be defined by users. Then, print analog sound data via serial port monitor.  
*Setup 1:Stack CoreUSB and Sensorhub.
+
<source lang="cpp">
[[File:CoreUSB_Sensorhub.jpg|600px|center|thumb]]
+
  int v=analogRead(A0);
*Setup 2:Connect Sound to A0 pin of Sensorhub and the colored LED light to A6. There is pin description on both sides of Sensorhub, which can be connected sensors correspondingly.
+
  Serial.println(v);
 
+
</source>
[[file:Microduino-sensorhub_rule.JPG|thumb|800px|center]]
+
*Detect sound volume every 100ms and distinguish the sound. Soudn range is defined in " zone_vol[3]", which is among 100-600. Users can change that according to personal needs.  
[[File:mic_colorled.jpg|600px|center|thumb]]
 
 
 
==Software Debugging==
 
*Setup 1:Build development environment, connect CoreUSB to your PC and download program code.  
 
 
 
 
 
*Setup 2:Code description: One part reads analog values and the other controls color combinationof the lantern according to the values.
 
**Read analog values.  
 
 
<source lang="cpp">
 
<source lang="cpp">
int v=analogRead(A0);
+
  if(millis()-timer[0]>100)
 +
  {
 +
    timer[0]=millis();
 +
    if(v>zone_vol[0])
 +
      zone=0;//Red
 +
    else if(v>zone_vol[1])
 +
      zone=1;//Green
 +
    else if(v>zone_vol[2])
 +
      zone=2;//Blue
 +
    else
 +
      zone=9;
 +
  }
 
</source>
 
</source>
**Color quantization
+
*The analog value decides color combination.
 
<source lang="cpp">
 
<source lang="cpp">
 
   switch(zone)
 
   switch(zone)
第50行: 第65行:
 
   case 0:
 
   case 0:
 
     if(color!=0)
 
     if(color!=0)
       vol[0]=map(v,0,1023,0,255);
+
       vol[0]=map(v,0,1023,0,255);//Red
 
     else
 
     else
 
       vol[0]=10;
 
       vol[0]=10;
第56行: 第71行:
 
   case 1:
 
   case 1:
 
     if(color!=1)
 
     if(color!=1)
       vol[1]=map(v,0,1023,0,255);
+
       vol[1]=map(v,0,1023,0,255);//Green
 
     else
 
     else
 
       vol[1]=10;
 
       vol[1]=10;
第62行: 第77行:
 
   case 2:
 
   case 2:
 
     if(color!=2)
 
     if(color!=2)
       vol[2]=map(v,0,1023,0,255);
+
       vol[2]=map(v,0,1023,0,255);//Blue
 
     else
 
     else
 
       vol[2]=10;
 
       vol[2]=10;
 
     break;
 
     break;
 
   }
 
   }
 
 
   // Some example procedures showing how to display to the pixels:
 
   // Some example procedures showing how to display to the pixels:
 
   colorWipe(strip.Color(vol[0],vol[1], vol[2]), 20);
 
   colorWipe(strip.Color(vol[0],vol[1], vol[2]), 20);
 
</source>
 
</source>
 +
 +
==Hardware Buildup==
 +
*Setup 1:Connect MIC to A0 pin of Sensorhub and Colored LED to A6. Both sides of Sensorhub have pin description, which can be connected with sensors accordingly.
 +
[[File:CoreUSB_mic_steup1.jpg|600px|center]]
 +
*Setup 2:Connect the activated battery box to BM.
 +
[[File:CoreUSB_Ble_steup2.jpg|600px|center]]
 +
*Setup 3:Stack all modules together without fixed order and finish the circuit buildup.
 +
[[File: music_mic_all.jpg|600px|center]]
  
 
==Result==
 
==Result==
Speak towards mic and you’ll be suprised about the effect.  
+
Speak towards MIC and you'll find different effect.  
[[File:mic_colorled——legao.jpg|600px|center|thumb]]
+
[[File:mic_colorled——legao.jpg|600px|center]]
  
 
==Video==
 
==Video==
  
 
|}
 
|}

2015年9月28日 (一) 09:29的最新版本

Language English

Objective

Speak toward MIC, the lamp will change along with the sound rhythm.

principle

  • MIC sensor introduction

MIC sensor can turn sound signal to electricity signal. It can detect sound volume but can't detect certain sound.

  • Rhythm Lamp

Detect sound volume via MIC sensor and the system will judge which color range the sound belongs to. At the same, comparing with the pre-set trigger value and choosing to open or close light change, therefore, to control color change of the lamp.

Equipment

Moudle Number Function
mCookie-CoreUSB 1 Core board
mCookie-Hub 1 Sensor pin board
Microduino-Sound 1 Sound detection sensor
Microduino-Color led 1 Colored LED light

Preparation

  • Setup 1:Connect CoreUSB and PC/Mac with USB cable and open Arduino IDE.
  • Setup 3:Load code, copy program to IDE. Select the right boardcard and COM port and then download after passing the compiling.

Program Description

  • Read sound analog value (A0 pin), which can be defined by users. Then, print analog sound data via serial port monitor.
  int v=analogRead(A0);
  Serial.println(v);
  • Detect sound volume every 100ms and distinguish the sound. Soudn range is defined in " zone_vol[3]", which is among 100-600. Users can change that according to personal needs.
  if(millis()-timer[0]>100)
  {
    timer[0]=millis();
    if(v>zone_vol[0])
      zone=0;//Red 
    else if(v>zone_vol[1])
      zone=1;//Green 
    else if(v>zone_vol[2])
      zone=2;//Blue
    else
      zone=9;
  }
  • The analog value decides color combination.
  switch(zone)
  {
  case 0:
    if(color!=0)
      vol[0]=map(v,0,1023,0,255);//Red 
    else
      vol[0]=10;
    break;
  case 1:
    if(color!=1)
      vol[1]=map(v,0,1023,0,255);//Green 
    else
      vol[1]=10;
    break;
  case 2:
    if(color!=2)
      vol[2]=map(v,0,1023,0,255);//Blue 
    else
      vol[2]=10;
    break;
  }
  // Some example procedures showing how to display to the pixels:
  colorWipe(strip.Color(vol[0],vol[1], vol[2]), 20);

Hardware Buildup

  • Setup 1:Connect MIC to A0 pin of Sensorhub and Colored LED to A6. Both sides of Sensorhub have pin description, which can be connected with sensors accordingly.
  • Setup 2:Connect the activated battery box to BM.
CoreUSB Ble steup2.jpg
  • Setup 3:Stack all modules together without fixed order and finish the circuit buildup.

Result

Speak towards MIC and you'll find different effect.

Video