Refrigerator Light

From Microduino Wiki
Revision as of 06:17, 14 October 2016 by Fengfeng (talk) (Created page with "{| style="width: 1000px;" |- | ==Outline== 600px|center Make a refrigerator light: open the door, then it can light up automatica...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Outline

Anywhere refrigerator-light.jpg

Make a refrigerator light: open the door, then it can light up automatically; close the door, the it will go off automatically.

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
  • Lego shell*1
  • Lego or other fixation structure
Anywhere trefrigerator-light-module.jpg


Module Setup

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


Programming

Programming Thought

When the door is open, the crash button isn’t squeezed (in release state) by it, LED is on; when the door is closed, the crash button is squeezed (in press state) by it, LED is off.

Start to Program

1. Open the door, and the crash button is “released”, then the LED is activated.
Change the pin of crash button into 6, and the state into released; change the digital output pin into 4, and set the state to high.

Mixly-ctrl-ttrefrigerator-code1.jpg

2. Close the door, and the crash button is “pressed”, the LED will go off.
Change the state of the crash button into 6, and set the state to press; change the digital output number into 6, and the set the state to low.

Mixly-ctrl-ttrefrigerator-code2.jpg

Test the result
After upload, when the crash button keeps pressed, the LED keeps off(representing the door is closed). When the crash button keeps free, the LED keeps on all the time(representing the door is open).

  • Q: Sometimes, I would forget to close the door, all things in the refrigerator will go melted, is there some way to alarm me?
  • A: you can add an alarming function, if the door is open for a certain period of time, it will produce alarming sound. For that, you can add a “timing” function. If the door hasn’t been closed for a period of time, the buzzer will ring to alarm!


Required Program Blocks

Programming Thought

Judge whether the crash button is released. If it isn’t( the door is closed), turn the LED off; if it is (the door is open), turn the LED on, and active the buzzer when the door has been open for a certain period of time.

Mixly-ctrl-timeout-light.jpg

Start to Program

1. When the door is open, the crash button 6 is free, turn the LED on.

Mixly-ctrl-timeout-light-code1.jpg

2. When it is overtime, the buzzer starts to alarm.
Define the timer timer1. Start to time. When the crash button is released, repeat executing the internal program (judge whether the timing time of timer 1 is over 4000ms, if it is, active the buzzer to alarm), until the crash button is pressed( close the door).

Mixly-ctrl-timeout-light-code2.jpg

3. After the door was closed, the LED and buzzer go off.

Mixly-ctrl-timeout-light-code3.jpg

Test the result
After upload the program, release the crash button, after 4s, check whether the buzzer alarms.

Anywhere refrigerator-light.jpg

Technical Specification

  • The product number of crash button: MSDS11
  • Digital signal input sensor.
  • For details, please refer to Sensor-Crash.

Related Cases

FAQ