Difference between revisions of "Rhythm Lamp"

From Microduino Wiki
Jump to: navigation, search
(Wrong Pin. Should be D6 instead of A6)
 
(One intermediate revision by one other user not shown)
Line 32: Line 32:
  
 
==Preparation==
 
==Preparation==
*Setup 1:Connect CoreUSB and PC/Mac with USB cable and open Arduino IDE.
+
*Setup 1: Connect CoreUSB and PC/Mac with USB cable and open Arduino IDE.
 
[[File:CoreUSB_Ble_pc.jpg|600px|center]]
 
[[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]
+
*Setup 2: Download program:[https://github.com/Microduino/Microduino_Tutorials/blob/master/MCookie_Tutorial/SHENGRI/SHENGRI.ino SHENGRI]
 
[[File: _SHENGR.jpg|600px|center]]
 
[[File: _SHENGR.jpg|600px|center]]
  
* Setup 3:Load code, copy program to IDE. Select the right boardcard and COM port and then download after passing the compiling.   
+
* Setup 3: Load code, copy program to IDE. Select the right boardcard and COM port and then download after passing the compiling.   
 
==Program Description==
 
==Program Description==
 
*Read sound analog value (A0 pin), which can be defined by users. Then, print analog sound data via serial port monitor.  
 
*Read sound analog value (A0 pin), which can be defined by users. Then, print analog sound data via serial port monitor.  
Line 44: Line 44:
 
   Serial.println(v);
 
   Serial.println(v);
 
</source>
 
</source>
*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.  
+
*Detect sound volume every 100ms and distinguish the sound. Sound range is defined in " zone_vol[3]", which is among 100-600. Users can change that according to personal needs.  
 
<source lang="cpp">
 
<source lang="cpp">
 
   if(millis()-timer[0]>100)
 
   if(millis()-timer[0]>100)
Line 87: Line 87:
  
 
==Hardware Buildup==
 
==Hardware Buildup==
*Setup 1:Connect MIC to A0 pin of Sensorhub and Colored LED to D6. Both sides of Sensorhub have pin description, which can be connected with sensors accordingly.  
+
*Setup 1: Connect MIC to A0 pin of Sensorhub and Colored LED to PIN 6. Both sides of Sensorhub have pin description, which can be connected with sensors accordingly.  
 
[[File:CoreUSB_mic_steup1.jpg|600px|center]]
 
[[File:CoreUSB_mic_steup1.jpg|600px|center]]
*Setup 2:Connect the activated battery box to BM.  
+
*Setup 2: Connect the activated battery box to BM.  
 
[[File:CoreUSB_Ble_steup2.jpg|600px|center]]
 
[[File:CoreUSB_Ble_steup2.jpg|600px|center]]
*Setup 3:Stack all modules together without fixed order and finish the circuit buildup.  
+
*Setup 3: Stack all modules together without fixed order and finish the circuit buildup.  
 
[[File: music_mic_all.jpg|600px|center]]
 
[[File: music_mic_all.jpg|600px|center]]
  

Latest revision as of 06:52, 30 September 2016

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.

Mic sch.jpg

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
Mic lamp.jpg

Preparation

  • Setup 1: Connect CoreUSB and PC/Mac with USB cable and open Arduino IDE.
CoreUSB Ble pc.jpg
  • 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. Sound 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 PIN 6. Both sides of Sensorhub have pin description, which can be connected with sensors accordingly.
CoreUSB mic steup1.jpg
  • 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.
Music mic all.jpg

Result

Speak towards MIC and you'll find different effect.

Video