Rhythm Lamp

From Microduino Wiki
Revision as of 08:40, 19 June 2015 by 1304410487@qq.com (talk) (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== ==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Language: English  • 中文

Purpose

To control the color of a lantern by detecting sound via mic sound detection sensor.

Principle

Equipment

Module Number Function
Microduino-CoreUSB 1 Core board
Microduino-Sensorhub 1 Sensor transfer board
Microduino-Sound/zh 1 Sound detection sensor
Microduino-Lantern 1 Colored light
Microduino-BM 1 Battery management


Mic lamp.jpg

Hardware Buildup

  • Setup 1:Stack CoreUSB and Sensorhub.
  • 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.
Microduino-sensorhub rule.JPG

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.
int v=analogRead(A0);
    • Color quantization
  switch(zone)
  {
  case 0:
    if(color!=0)
      vol[0]=map(v,0,1023,0,255);
    else
      vol[0]=10;
    break;
  case 1:
    if(color!=1)
      vol[1]=map(v,0,1023,0,255);
    else
      vol[1]=10;
    break;
  case 2:
    if(color!=2)
      vol[2]=map(v,0,1023,0,255);
    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);

Result

Speak towards mic and you’ll be suprised about the effect.

Video