Outline
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
Other Equipment
- USB cable*1
- Sensor cable*3
- Sensor shell*1
- Lego or other fixation structure
Module Setup
Setup
- 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.
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.
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.
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.
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.
|