Beleuchtete Geschenkboxen als Weihnachtsdekoration - AZ-Delivery

Christmas is just around the corner and it is time to decorate our house with Christmas motifs. Windows and the Christmas tree are also provided with lights and jewelry. Santa Claus leaves his gifts under the Christmas tree.

In this project we will produce very special, colorful and striking gift boxes. Hashes that attract attention and change color.

Required hardware and materials

Required software, libraries and sketch

Circuit diagram and description of the structure

Download of the circuit diagram

The three LED panels are connected to the digital pins 6, 7 and 8 of the AZ-MEGA2560 microcontroller. The 5 VDC voltage required for the supply of the LED panels must be supplied by a power supply with sufficient power. The microcontroller is also supplied by the external 5 VDC source. Either like here on the USB port, the external socket, or the Vin Pin. The circuit for this project is very easy because only three LED panels and the microcontroller are required.

Assembly

For the construction of the boxes, the frames of the cubes are built from the square bars. For the small box, 12 bars of 10 cm in length, for the middle box 12 rods of 17 cm length and 12 rods for the large box of 22 cm are cut. The corners of the woods are glued together.

We use white DIN-A4 paper for the walls of the boxes for the middle and the small box and also white DIN-A3 paper for the large box. The paper is slightly translucent and ensures that the light of the LEDs spread and make homogeneous. Balsa or poplar plywood in the same size is used for the bottom of the boxes as the sides of the boxes. The LED modules are then installed.

Description of the sketch

The boxes change the colors defined by us and in the interval defined by us. The source code is precisely described in the sketch.

The three libraries Fastled, Adafruit_NoMatrix and adafruit_neopixel are needed to control the LEDs.

#include "Fastled.H"
#include <Adafruit_neomatrix.H>
#include <Adafruit_neopixel.H>

Next, the number of LEDs and the pins used are defined as constants.

#define num_leds_big_box 256
#define Pin_Big_Box 7
#define Pin_Medium_Sized_Box 8

#define NUM_LEDS_SMALL_BOX 64
#define Pin_small_Box 6
  • A neomatrix object is created for each panel, to which the following parameters are handed over:
  • Number of LEDs in the width and height of the panel (LEDs in width and LEDs in height) and the PIN of the microcontroller, to which the data line of the LED panel is connected to the microcontroller.
  • Position of the LED number 0 on the panel, LED 0 is located on the bottom right of the panel.
  • Arrangement of the LEDs on the control panel and progression of the numbering. The LEDs are arranged in columns. At neo_matrix_zigzag it is stated that the LED numbering progresses like a snake in a zigzag when a column ends, the next LED on the left of the next column begins. With neo_matrix_progressive, the arrangement is designed in such a way that when a column ends, the next as well as the previous one begins.
  • The arrangement and wiring of the three internal LEDs. The internal arrangement is a green, red and blue LED (Neo_grb). The last parameter is the working frequency (800 kHz).
Adafruit_neomatrix big_box_matrix = Adafruit_neomatrix(16, 16, Pin_Big_Box,
                Neo_matrix_bottom + Neo_matrix_right +
                Neo_matrix_columns + Neo_matrix_zigzag,
                Neo_grb + Neo_khz800);

Adafruit_neomatrix medium_sized_box_matrix = Adafruit_neomatrix(16, 16, Pin_Medium_Sized_Box,
                Neo_matrix_bottom + Neo_matrix_right +
                Neo_matrix_columns + Neo_matrix_zigzag,
                Neo_grb + Neo_khz800);

Adafruit_neomatrix small_box_matrix = Adafruit_neomatrix(8, 8, Pin_small_Box,
                Neo_matrix_top + Neo_matrix_right +
                Neo_matrix_columns + Neo_matrix_progressive,
                Neo_grb + Neo_khz800);

After implementing the libraries and the definition of the variables, the LED panels must be initialized. This happens in the set up()-Method in which the initial state of the LEDs is also configured.

big_box_matrix.Begin();
medium_sized_box_matrix.Begin();
small_box_matrix.Begin();

big_box_matrix.clear();
medium_sized_box_matrix.clear();
small_box_matrix.clear();

The methods that are responsible for the lighting are called up in the continuous Loop () method. They all work the same, except for a 50ms break, so I only describe one of the methods.

First, the lighting for the large box is called.

big_box_matrix_red();    

When performing this method, the brightness of the LEDs is first set to half of the maximum value (125 of 254). Then a loop is carried out, which runs from the first LED in position 0 to the last in position 255 (a total of 256 LEDs), sets it to red and switches on. After switching on all LEDs, a break of 3 seconds is inserted before the method Loop () Returned and the next line is executed. In this case the call of the method medium_sized_box_matrix_yello (), the middle box. The execution of this method is similar to the color and the box described above, on which the change is to be made. You can find a list of "Predefined Colors" here In the description of the Fastled Library.

void big_box_matrix_red() {
        big_box_matrix.setbrightness(125);
        for (intimately I=0; I<num_leds_big_box; I++) {
                big_box_matrix.setpixelcolor(I, CRGB::Red);
                big_box_matrix.show();
        }
        delay(3000);
}

The only change in the method for changing the color of the small box is a delay of 50ms within the FOR loop.

void small_box_matrix_red() {
        small_box_matrix.setbrightness(125);
        for (intimately I=0; I<NUM_LEDS_SMALL_BOX; I++) {
                small_box_matrix.setpixelcolor(I, CRGB::Red);
                small_box_matrix.show();
                delay(50);
        }
        delay(3000);
}

The different methods make the gift boxes shine in different colors.

Sketch download

We hope that you liked this Christmas decoration project and wish you a Merry Christmas.


If you don't see the video, you have to allow cookies in your browser

Für arduinoSpecials

Laisser un commentaire

Tous les commentaires sont modérés avant d'être publiés

Articles de blog recommandés

  1. ESP32 jetzt über den Boardverwalter installieren - AZ-Delivery
  2. Internet-Radio mit dem ESP32 - UPDATE - AZ-Delivery
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1 - AZ-Delivery
  4. ESP32 - das Multitalent - AZ-Delivery