Christmas and new year are coming. It means a festive mood, gifts and, of course, a Christmas tree decorated with bright colorful lights.
For me, mass-market Christmas tree lights are too boring. To please children, I made a unique Christmas tree decoration which is controlled by a toy.
In this manual, I'm going to tell how you can make it.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Idea.
The idea is to put a toy, for example, a soft one, under the Christmas tree, and make it smart. I want a toy to read the color of any attached object, and to paint a tree in this color. Thus, it will be a fun game for children who can use different things to paint the Christmas tree in different colors.
Step 2: Preparation. LED Strip.
First, I have to find a replacement for the usual Christmas lights.
New lights should be bright, colored, and most importantly they should be easy to program.
For Christmas lights, I chose addressable programmable digital RGB ws2812b LED strip. These LED strips are very popular, you can find them anywhere. They are easy to connect to various Arduino controllers. Such LEDs are sold in tapes of several dozen pieces and are powered by 5 12 or 24 V DC. You can link several tapes in a row and manage a huge number of LEDs.
I found a couple of such strips at home. My strips have 50 LEDs each and are driven by 5 V DC.
Here is a possible replacement from the Amazon store:
- WS2812b 5m 60leds/pixels/m Flexible Individually Addressable Led Strip
- ALITOVE 16.4ft WS2812B Individually Addressable LED Strip Light
LED tapes have a lot of varieties. They differ in the number of LEDs, the distance between LEDs, grouping, supply voltage, etc. Choose what you want.
For my toy, I prepared a little Christmas tree, so 100LEDs are enough for me.
Step 3: Preparation. Toy.
Find the toy and decide where to place the LED strip controller.
This step is the most important because the result will be evaluated by children =).
In a nearby toy store, I found a wonderful new year bear. You can improve a toy that you already have.
I decided to cover the LED strip controller with a fabric and sew it to bears paws. I want the bear looks like it is holding a present.
I bought two pieces of fabric with funny patterns. One is soft for the substrate and the second is thin for the top layer.
Step 4: Preparation. Electronics.
You need some electronic components to make toy smarter.
I use breakout boards and Arduino shields from the Amperka store. As for me, they are very convenient because of a modular structure. Modules can be easily combined without soldering.
You may find it difficult to purchase them, so I include links with a possible replacement.
I use ESP-12 development board based on the ESP8266 chip. These boards are super tiny and have enough functionality. Good choice for small projects requiring limited space, even if you don't use WiFi and connect to the Internet.
1 x Amperka Wi-Fi Slot ~ 19$
I use this development board cause it is compatible with other modules from the same manufacturer.
Also, it has a square form! It should easily fit in a small present box for the bear.
To determine the color I use Amperka Troyka TCS34725 color sensor breakout board. My sensor is compatible with the controller board but it can be replaced with this one:
This sensor uses an I2C interface for communication. It has built-in bright LED and extensive settings like color gain or color integration for more accurate recognition.
A simple Arduino compatible button. I use it as a touch sensor, notifying the controller that it is necessary to read the color of a new item.
1 x Amperka Troyka button module ~ 1$
AC-DC voltage converter
To power the LED strip and controller, I purchased the AC-DC 5V 8A power supply.
1 x 5V 8.0A 40W power supply ~16$
My LED strip is powered by 5V. 8A current is enough for a huge number of LEDs. I also power the ESP controller from this power supply. Be sure to purchase power supplies in insulated enclosures, without open contact pads!
- ALITOVE 5V 8A 40W AC to DC Adapter Power Supply Converter
- MEAN WELL original LPV-60-5 5V 8A meanwell LPV-60 5V 40W
DC-DC voltage converter and WS2812b driver
For Arduino controllers, the signal wire of the ws2812b LED strip can be directly connected to pins on the controller board. Most of ESP8266 development board pins are not compatible with 5V logic. It is better now to connect the LED strip to such controllers directly. To solve this problem I use this module.
I use this module because it easily attaches to my controller. Also, the module has a 5 Volt logic buffer and DC-DC voltage Converter 5 or 3.3V. This way ESP controller can be powered by one wire together with 12 or 24V LED strip.
Step 5: Assembling. Electronics.
Assemble electronic components. I connected my components as it is shown in the attached diagram.
The scheme may differ depending on your components, but the meaning remains the same.
- Connect a button to the controller. I connected it to A2 Esp8266 pin. If you are not using a module, you can connect a common momentary button through a resistor.
- Connect a color sensor to the controller. TCS34725 color sensor breakout boards communicate using I2C bus. Link SDA and SCL pins between the sensor and the controller. If your sensor board has LED pin to control the integrated LED, connect it. I linked my LED pin to the A0 Esp8266 pin.
- Connect one end of the LED strip to the controller. ws2812b LED strip connects to a controller using the DI pin. The logic voltage for ws2812b LED strips is 5V. If you are using an Arduino like boards, you can connect the DI pin directly to the pin of the controller. The logic level voltage for most of the Esp8266 boards is 3.3V, so use a logical level converter or the LED strip driver. I soldered DI Strip wire to the driver board and connected driver board to the A5 Esp8266 pin.
- Attach another end of the LED strip to the power supply. The one with the DO pin. If it is necessary, solder the plug to the power supply. Do not forget to isolate wires.
My ws2812b LED strip is powered by 5V. I powered both the strip and the controller from a single AC-DC 5V power supply. If your LED strip operates 12 or 24V, use the downgrading voltage converter to power all electronics form single power supply.
Step 6: XOD.
Let's program the controller.
As in my previous projects, I use the XOD visual programming environment for controller firmware.
I've published a couple of libraries that you will need to create a program. So, be sure to add them into your XOD workspace.
- gabbapeople/christmas-tree - Library contains ws2811 Neopixel driver and the wrapper for a tcs34725 color sensor.
gabbapeople/color - Library to work with color in XOD.
Next, I'm going to describe how to program this device in XOD.
Step 7: Programming.
Here are nodes you need:
The tsc-color-sensor node.
This is the first node to place onto the patch. It is used to measure the color value from the sensor. Node uses the I2C interface to exchange data.
The color sensor detects the color of the surface in the RGB scale. Color is the result of interaction between a light source, an object, and an observer. In case of reflected light, light falling on an object will be reflected or absorbed depending on surface characteristics. Most color sensors contain a white light emitter and three light intensity sensors with color filters.
- LED and LUM input pins are for the built-in LED on the breakout board of the sensor. This built-in LED is a light emitter of the sensor. According to my scheme, I put the A0 value to the LED pin and set the 1 luminance value to the LUM pin.
- The IT pin sets the integration time value. This factor describes a number of cycles to integrate a color. Possible values of IT are 1, 10, 20, 42, 64, 256.
- The GAIN pin value is an amplification factor. This coefficient enhances the color. You can enhance the color value by 4, 16 or 60 times. You can not enhance the color. Then the value on the GAIN pin must be equal to 1. I got the most accurate result using the 20 IT value and 60 GAIN value.
- The INIT pin triggers the sensor initialization and sets up custom factors. I change the INIT pin value to On boot.
- The UPD pin triggers new sensor reading. Let this value be Continuous.
The tcs-color-node outputs a color value in a form of color custom type.
The ws2811 node.
This node is used to set up the LED strip or matrix.
- DI pin is for the board port number the LED strip or matrix is connected to. According to my scheme, I put the A5 value to it.
- Put the number of LEDs used to the SIZE pin. I have 2 led strips of 50 diodes connected to each other, so I set the SIZE value to 100.
The B pin sets the overall brightness for all LEDs in a range from 0 to 100. I set the brightness to 80.
This node initializes your LED strip or matrix and constructs a ws2811 custom type for further operations.
The color-all node.
When the ws2811 node is installed, you can control the LED strip using different functional nodes.
- color-all. Node paints all LEDs on the strip or matrix in a selected color.
- color-pixel. Node colors particular LED on the strip in the selected color. Put the pixel number to the PN pin.
- color-n-pixels. Node colors a group of N LEDs in the selected color. Specify the start LED number of the group using the STRT pin. Specify the orderliness of a group at the STEP pin. For example, to paint every second LED starting with the number 30 and ending with the number 70 put the following values: STRT = 30; N = 40 (70 - 30); STEP = 2.
In this project, I control all LEDs at the same time and use the color-all node.
I link the first input pin of the color-all node with the output pin of the ws2811 node. Then I link the input CLR pin which takes the color value to the output pin of the sensor.
A pulse on the SET pin of the color-all node triggers a new color set.
The button node.
I use the button to inform the controller about a new object in front of the color sensor. For this, I place the button node onto the patch and link its output PRS pin with the SET pin of the color-all node. This way, clicking on the button generates a pulse signal to change the color.
I attached the button to the A2 Esp8266 pin, so I put A2 value to the PORT pin.
The purify node.
The color sensor can output color values in a huge range. But the LED strip is not able to display in-between tints. To solve this I use only so-called pure colors. They have an arbitrary hue, but always have their saturation at maximum. To purify a color value I place the purify node between tsc-color-sensor and color-all nodes.
The patch is ready.
You can press Deploy, choose the board type and upload it to the device.
Step 8: Assembling. Frame.
I can start creating a soft case, making sure that the device works as it should.
As a frame, I printed a pattern of the box on thick cardboard.
Then bent the box sides and made a square hole for the color sensor.
I made this case specifically for my electronic components, which most likely differ from yours. The case is not universal, besides you can have a completely different toy. So use imagination!
Step 9: Assembling. Fabric.
I put two different fabrics on each other.
Soft thick fabric is for volume and thin is for appearance. In both fabrics, I also made a hole for the sensor.
I fixed the cardboard frame on the fabric with ordinary adhesive tape. In the same way, I fixed the edges of the hole.
Then I cut off extra fabric pieces and hand-stitched the contour of the hole from the inside.
I have to say, I am not the best seamster, so don't judge the quality. =)
Step 10: Assembling. Soft Case.
I stretched the fabric and fixed it with the same adhesive tape. The tape will remain inside of the case and will not be visible.
Then, I placed the device in a frame and completely sewed it around the contour, except for one corner where the wires go.
Step 11: Assembling. Toy and Device.
I sewed my device to the paws of a teddy bear.
I wanted it to look like he is holding a little Christmas gift.
Step 12: Result.
Once the device is programmed and fixed to the toy, you can connect the LED strip and put the toy under the tree!
Attach colored objects to the teddy bears gift and the tree will be painted in the same color!
Subscribe If you like this mini-project! =)
There will be a lot of different funny instructions.
Participated in the