Difference between revisions of "Multi-Functional Flashlight"

From Microduino Wiki
Jump to: navigation, search
(Related Cases)
 
Line 41: Line 41:
 
*Assemble the modules and sensors together:  
 
*Assemble the modules and sensors together:  
 
**Stick the red core modules, USB upload module and green extension module together;  
 
**Stick the red core modules, USB upload module and green extension module together;  
**Connect the red LED to pin 的6/7 of Hub;
+
**Connect the red LED to pin 6/7 of Hub;
 
**Connect the crash to pin 4/5 of Hub;
 
**Connect the crash to pin 4/5 of Hub;
 
**Insert one end of USB cable into the USB upload module, and connect the other to computer;  
 
**Insert one end of USB cable into the USB upload module, and connect the other to computer;  
Line 48: Line 48:
 
==Programming==
 
==Programming==
 
===Required Program Blocks===
 
===Required Program Blocks===
*[[“Digital write” program block]]
+
*[["Digital write" program block]]
*[[“Crash sensor” program block]]
+
*[["Crash button" program block]]
 
 
 
 
  
Line 56: Line 56:
 
[[File:mixly-ctrl-flashlight.jpg|600px|center]]
 
[[File:mixly-ctrl-flashlight.jpg|600px|center]]
 
===Programming===
 
===Programming===
1、'''Switch 4 is pressed, then LED 6 emits strong light'''
+
1. '''Switch 4 is pressed, then LED 6 emits strong light'''
 
<br>
 
<br>
Set the pin of “crash” program block to 4, and the state to press; set the “analog output” pin to 6, and assign 255 to it; set delay to 1000ms.  
+
Set the pin of "crash button" program block to 4, and the state to press; set the "analog output" pin to 6, and assign 255 to it; set delay to 1000ms.  
 
[[File:mixly-ctrl-flashlight-code1.jpg|600px|center]]
 
[[File:mixly-ctrl-flashlight-code1.jpg|600px|center]]
2、'''Switch 4 is pressed, and the LED 6 emits weak light.'''
+
2. '''Switch 4 is pressed, and the LED 6 emits weak light.'''
 
<br>
 
<br>
Set the pin of crash to 4, and the state to press; set the pin of program block of “analog write” to 6, and assign 50 to it; delay 1000ms.  
+
Set the pin of crash to 4, and the state to press; set the pin of program block of "analog write" to 6, and assign 50 to it; delay 1000ms.  
 
[[File:mixly-ctrl-flashlight-code2.jpg|600px|center]]
 
[[File:mixly-ctrl-flashlight-code2.jpg|600px|center]]
 
3、'''Switch 4 is pressed, and the LED 6 goes off.'''
 
3、'''Switch 4 is pressed, and the LED 6 goes off.'''
 
<br>
 
<br>
Set the pin of “crash” program block to 4, and the state to press; set the pin of “analog write” program block to 6, and assign 0 to it; delay 1000ms.  
+
Set the pin of "crash button" program block to 4, and the state to press; set the pin of "analog write" program block to 6, and assign 0 to it; delay 1000ms.  
 
[[File:mixly-ctrl-flashlight-code3.jpg|600px|center]]
 
[[File:mixly-ctrl-flashlight-code3.jpg|600px|center]]
 
4. So link the program blocks together, and choose the core and port to download program.  
 
4. So link the program blocks together, and choose the core and port to download program.  

Latest revision as of 10:27, 9 October 2016


Outline

Anywhere flashlight.jpg

Make a multi-functional flashlight, which can be lighting, and the brightness is adjustable.

Suitable kits: mCookie102, mCookie202, mCookie302, IBC


Module Bill

Module

Module Number Function
mCookie-Core 1 Core board
mCookie-USBTTL 1 Program download
mCookie-Hub 1 Sensor adapter plate
Crash 1 Crash sensor
LED 1 Single color LED

Other Equipment

  • USB cable*1
  • Sensor cable*1
  • Sensor shell*1
  • Lego or other fixation structure
Anywhere table-lamp-module.jpg


Module Setup

Anywhere table-lamp-module—step.jpg
  • Assemble the modules and sensors together:
    • Stick the red core modules, USB upload module and green extension module together;
    • Connect the red LED to pin 6/7 of Hub;
    • Connect the crash to pin 4/5 of Hub;
    • Insert one end of USB cable into the USB upload module, and connect the other to computer;


Programming

Required Program Blocks

 

Programming Thought

Press the switch, the light is the most bright; press again, the light gets dark; press the third time, the light goes off. Adjust the brightness of the flashlight through “switch”.

Mixly-ctrl-flashlight.jpg

Programming

1. Switch 4 is pressed, then LED 6 emits strong light
Set the pin of "crash button" program block to 4, and the state to press; set the "analog output" pin to 6, and assign 255 to it; set delay to 1000ms.

Mixly-ctrl-flashlight-code1.jpg

2. Switch 4 is pressed, and the LED 6 emits weak light.
Set the pin of crash to 4, and the state to press; set the pin of program block of "analog write" to 6, and assign 50 to it; delay 1000ms.

Mixly-ctrl-flashlight-code2.jpg

3、Switch 4 is pressed, and the LED 6 goes off.
Set the pin of "crash button" program block to 4, and the state to press; set the pin of "analog write" program block to 6, and assign 0 to it; delay 1000ms.

Mixly-ctrl-flashlight-code3.jpg

4. So link the program blocks together, and choose the core and port to download program.
Test the result:
Each time you press the switch, the brightness of LED will change. Make a flashlight with Lego, and install the switch and LED in the right place. Pay attention to the shell should be suitable for carrying.

Anywhere flashlight.jpg

Technical Specification

  • The product number of the crash sensor: MSDS11
  • Crash sensor is belong to digital signal input sensor.
  • For details, please refer to Sensor-Crash

Related Cases

Q&A