Difference between revisions of "Sound Control Lamp"

From Microduino Wiki
Jump to: navigation, search
(Required Program Blocks)
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
 
[[File:anywhere_mic light.jpg|600px|center]]
 
[[File:anywhere_mic light.jpg|600px|center]]
  
Make a sound and light control lamp, which can only be activated when the two conditions “no light” and “sound” both are matched.  
+
Make a sound and light control lamp, which can only be activated when the two conditions "no light" and "sound" both are matched.  
 
<br>
 
<br>
 
Suitable kits: mCookie302, IBC
 
Suitable kits: mCookie302, IBC
Line 20: Line 20:
 
|-
 
|-
 
|[[mCookie-Battery|Battery box]]||1||Program download and power supply
 
|[[mCookie-Battery|Battery box]]||1||Program download and power supply
 +
|-
 
|[[mCookie-Hub|mCookie-Hub]]||1||Sensor adapter plate
 
|[[mCookie-Hub|mCookie-Hub]]||1||Sensor adapter plate
 
|-
 
|-
Line 40: Line 41:
 
[[File:anywhere_mic light-step.jpg|600px|center]]
 
[[File:anywhere_mic light-step.jpg|600px|center]]
 
*Assemble modules and sensors:
 
*Assemble modules and sensors:
**Stick the red core module, battery base and green extension module together;
+
**Stick the red core module, battery base and green extension module together;
 
**Connect the color LED cable to pin 6/7 of Hub;  
 
**Connect the color LED cable to pin 6/7 of Hub;  
 
**Connect the light sensor cable to pin 4/5 of Hub;  
 
**Connect the light sensor cable to pin 4/5 of Hub;  
Line 47: Line 48:
 
==Programming==
 
==Programming==
 
===Required Program Blocks===
 
===Required Program Blocks===
*[[“ColorLED prepare” program block]]
+
*[["ColorLED prepare" program block]]
*[[“ColorLED control” program block]]
+
*[["ColorLED control" program block]]
*[[“Light sensor” program block]]
+
*[["Light sensor" program block]]
*[[“Mic sensor” program block]]
+
*[["Mic sensor" program block]]
*[[“Delay” program block]]
+
*[["Delay" program block]]
*[[“And”, “or” program block]
+
*[["And", "or" program block]]
  
 
===Programming Thought===
 
===Programming Thought===
Only the two conditions “no light” and “sound” are all matched can it be activated.  
+
Only the two conditions "no light" and "sound" are all matched can it be activated.  
 
[[File:mixly-ctrl-mic light.jpg|600px|center]]
 
[[File:mixly-ctrl-mic light.jpg|600px|center]]
  
Line 63: Line 64:
 
ColorLED prepare, the LED number is 1, and the pin is 6.  
 
ColorLED prepare, the LED number is 1, and the pin is 6.  
 
<br>
 
<br>
Use “if-do” program block, if the light sensor detects no light, and the Mic sensor detects sound, the colorLED on program will be executed. Delay 2s, and then the color LED goes off, waiting for the next activating.  
+
Use "if-do" program block, if the light sensor detects no light, and the Mic sensor detects sound, the colorLED on program will be executed. Delay 2s, and then the color LED goes off, waiting for the next activating.  
 
[[File:mixly-ctrl-mic light-code.jpg|600px|center]]
 
[[File:mixly-ctrl-mic light-code.jpg|600px|center]]
 
'''Test the result'''
 
'''Test the result'''
 
<br>
 
<br>
After upload, when cry to the Mic sensor within strong light, the LED won’t light up. If you cover the light sensor with your hand, and then cry, the color LED will be activated.
+
After upload, when cry to the Mic sensor within strong light, the LED won't light up. If you cover the light sensor with your hand, and then cry, the color LED will be activated.
 
[[File:anywhere_mic light.jpg|600px|center]]
 
[[File:anywhere_mic light.jpg|600px|center]]
 
<br>
 
<br>
Line 77: Line 78:
 
'''Add a touch sensor, when there is no light, pressing the touch button or detecting sound can activate the color LED.'''
 
'''Add a touch sensor, when there is no light, pressing the touch button or detecting sound can activate the color LED.'''
 
<br>
 
<br>
Use two “if-do” program block nested. First, judge whether there is light, and then judge whether the touch button is pressed or whether there is sound.  
+
Use two "if-do" program block nested. First, judge whether there is light, and then judge whether the touch button is pressed or whether there is sound.  
 
[[File:mixly-ctrl-mic light-code1.jpg|600px|center]]
 
[[File:mixly-ctrl-mic light-code1.jpg|600px|center]]
  

Latest revision as of 03:31, 10 October 2016

Outline

Anywhere mic light.jpg

Make a sound and light control lamp, which can only be activated when the two conditions "no light" and "sound" both are matched.
Suitable kits: mCookie302, IBC


Module Bill

Module

Module Number Function
mCookie-Core 1 Core board
Battery box 1 Program download and power supply
mCookie-Hub 1 Sensor adapter plate
Sound sensor 1 Detect the strength of sound
Light sensor 1 Detect the strength of light
ColorLED 1 Color LED

Other Equipment

  • USB cable*1
  • Sensor cable*3
  • Sensor shell*1
  • Lego or other fixation structure
Anywhere mic light-module.jpg

Module Setup

Setup

Anywhere mic light-step.jpg
  • Assemble modules and sensors:
    • Stick the red core module, battery base and green extension module together;
    • Connect the color LED cable to pin 6/7 of Hub;
    • Connect the light sensor cable to pin 4/5 of Hub;
    • Connect the Mic sensor cable to pin 2/3 of Hub;
    • Insert one end of USB cable into the battery base, and connect the other to computer;

Programming

Required Program Blocks

Programming Thought

Only the two conditions "no light" and "sound" are all matched can it be activated.

Mixly-ctrl-mic light.jpg

Start to Program

If there is no light but sound, the LED will be activated.
ColorLED prepare, the LED number is 1, and the pin is 6.
Use "if-do" program block, if the light sensor detects no light, and the Mic sensor detects sound, the colorLED on program will be executed. Delay 2s, and then the color LED goes off, waiting for the next activating.

Mixly-ctrl-mic light-code.jpg

Test the result
After upload, when cry to the Mic sensor within strong light, the LED won't light up. If you cover the light sensor with your hand, and then cry, the color LED will be activated.

Anywhere mic light.jpg


Q: This smart sound control lamp can only light up when you cry to it without light. So, if it gets destroyed, is there an emergency plan?
A: We can add a way to control it, such as adding a touch button, in case of an emergency, press the touch button, and the color LED will be activated.

Add a touch sensor, when there is no light, pressing the touch button or detecting sound can activate the color LED.
Use two "if-do" program block nested. First, judge whether there is light, and then judge whether the touch button is pressed or whether there is sound.

Mixly-ctrl-mic light-code1.jpg


Technical Specification

  • Product number of light sensor: MSDT42
  • Product number of Mic sensor: MSDI11
  • Analog input sensor
  • For details about light sensor, please refer to Sensor-Light-A1
  • For details about Mic sensor, please refer to Sensor-MIC


Related Case


FAQ

  • Q: Are the light sensor and Mic sensor digital signal sensors? Can they only be connected to digital ports?
    • A: Light sensor is analog sensor, which can convert the strength of light into that of the electric signal whose range is 0-5V. If connected to digital port and the converted voltage is larger than 2.5V(strong light), the range is 1(true), otherwise(weak light), it is 0(false). The Mic sensor is in the similar way.