Colorful Landscape Lamp

From Microduino Wiki
Jump to: navigation, search

Outline

Anywhere colorled.jpg

Let's make a landscape lamp, which has many colors. 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
Touch Button 1 Detect the touch
Color LED 2 Color LED

Other Equipment

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

Module Setup

Learn about the Color LED

Full-color LED, can emit light of any color. Many of it can be cascaded together.
Connection
The color LED has two interfaces, which are labeled "IN" and "OUT" respectively. For example, 2 color LEDs are needed now, and the control pin should be connected to pin 6/7 of Hub;
It should be paid attention to here that when connect the LED 1 from the pin 6/7 of Hub, it should be connected to the IN port of the LED 1, and when connect the LED 2, you should connect to the OUT port of LED 1 and the IN port of LED 2.

Anywhere colorled-Connect—step.jpg

Difference between the crash sensor and touch sensor
The crash sensor converts the mechanical quantity into electricity, and the touch sensor converts the capacitance into electricity. Being pressed, the crash sensor will produce mechanical dither, so you should add delay to the program to eliminate the dither judge.
Being pressed, the touch sensor hasn't mechanical dither, so you needn't to add delay to the program. Our hands and touch sensors all have static electricity, so the touch sensor can induce the approaching of our hands and other conductive objects.

Anywhere touch-crash.jpg


Anywhere touch-crash-step.jpg
  • Assemble the modules and sensors:
    • Stick the red core module, battery base and green extension module together;
    • Connect the full-color LED to pin 6/7 of Hub(pay attention to that connect the IN of the first LED to the sensor adapter plate, and connect the OUT to IN of the second LED);
    • Connect the touch sensor to pin 4/5 of Hub;
    • Insert one end of USB into the battery base, and connect the other to computer;

Programming

Required Program Blocks

Programming Thought

*The first time pressing the touch button, the two color LEDs change into red; *The second time pressing the touch button, the two color LEDs change into blue; *The third time pressing the touch button, the two color LEDs go off.

Mixly-ctrl-colorled.jpg

Start to Programming

1. The first time you press the touch sensor, the two full-color LED change into red.
Because there are totally 2 full-color LEDs to use, set the LED number of "ColorLED prepare" to 2, and the control pin to 6. After the touch sensor is pressed, LED 1 and 2 are on red; delay 1000ms to release.

Mixly-ctrl-colorled-code1.jpg

2. The second time pressing the touch button, the two color LEDs change into blue.

Mixly-ctrl-colorled-code2.jpg

3.The third time pressing the touch button, the two color LEDs go off..

Mixly-ctrl-colorled-code3.jpg

Test the result
After upload, press the touch sensor, and the full-color LED will change among red, blue, and off three states. In this way, we have completed the program of the landscape lamp.

Anywhere colorled.jpg

Technical Specification

  • Product number of color LED: MSDL11
  • You will use API library to drive.
  • For details, please refer to Sensor-Color LED

Related Cases

FAQ

  • Q: How many color LEDs can be supported at most in cascade?
  • A: Under the condition that the power supply supports, 1024 at most. Too many will result in insufficient power supply, and the power should be strengthened.