Weihnachten 2025 – Animierter Schneewürfel - Teil 1

   If there is a special element in Christmas decorations, it is probably the Christmas snow globes, which usually contain a snowman or Santa Claus and which, when shaken, create a blizzard inside. For Christmas this year they want to take up this idea, but adapt it to the world of Arduino, which is why the glass ball has to be replaced by a transparent urn. No liquid is allowed to be used, so attempts are made to simulate the blizzard with fans and small down feathers from a feather duster. The animation is provided by a small train that travels outside a small village while a little Santa Claus flies over the village in his sleigh.

   Since lighting with messages cannot be missed at Christmas, Christmas will be congratulated with lighting, lighting will also be simulated inside some houses in the village, and so that the project will attract attention, it will be accompanied by music and sounds.

   This Christmas project is divided into two parts: the first part involves assembling the structure and elements of the project and installing the two DC motors that move both the train and Santa Claus and the interior lights of some houses in the village. In the second part, the project is completed with the installation of a WS2812B LED display to display news, the sound system and the fans.

The materials required for the entire project are:

 

        1 Microcontroller board AZ-ATmega328

        1 Double H-Bridge DC Motor Controller Board Module AZ-L298N

        1 Mini MP3 Player Master Modules

        1 PAM8403 digital mini audio amplifier 2x 3 Watt DC 5V board with potentiometer

        2 mini speakers 3 watts 8 ohms

        1 4-channel relay module 5V with optocoupler low-level trigger

        2 DC brushless fan heatsink cooler separation interface 3.3V 5V

        2 TT Motor DC3V-6V Gear Motor Double Shaft

        6 330 ohms resistors

        6 3mm white LEDs

        1 1 Kohm resistor

        1 5 Kohm potentiometer

        1 RGB LED panel WS2812B 16x16 256 LEDs

        Jumper wire cable 3 x 40 pieces. 20cm M2M/F2M/F2F

        MB-102 breadboard with 830 contacts

        Plywood panels, wood, 420 x 300 x 3 mm

        Acetate Sheets A4

        White wood glue

        Mosquito net

 

The required software is:

        Arduino IDE

        Adafruit GFX library (Arduino Adafruit_GFX.h)

        Adafruit NeoPixel library (Arduino Adafruit_NeoPixel.h)

        SoftwareSerial library (SoftwareSerial.h)

        Adafruit_NeoMatrix library (Adrafruit_NeoMatrix.h)                                                                                                    

        DFPlayer mini library from DFRobot (DFRobotDFPlayerMini.h)

        SPI.h library (included in the Arduino IDE)

        001.mp3

        002.mp3

        003.mp3

        snow_cube_animated_part_1.ino

 

 

The drawings of the characters are:

      For trees.jpg

       Santa.jpg

      Stadt.jpg

      Zug.jpg

      Dimensions of parts


Circuit diagram and description of the modules used in the final project

 

Drawing 2 – Snow Cube Drawing Part 2


How the project works

   When the second part of the project is completed and operational, the train will travel in one direction while Santa Claus will travel in the opposite direction as it snows in the small village. In the background of the landscape there is an LED matrix that displays the congratulatory message. Images can also be displayed if desired. During operation, the train sound, the ringing of Santa's reindeer bells and Christmas music alternate. The music files can be customized. Copyright-free files have been uploaded in this project.

   To move both the train and Santa's sleigh, DC motors are used. A 6 mm thick wheel with a rubber edge was coupled to the motor that drives the train, which rotates a wooden ring on which the train is installed. For the movement of Santa Claus, a wire is attached, at one end of which Santa Claus is attached and the other end must be installed on the motor axis. Both motors are powered and controlled by the L298N motor control module. Small pieces of a feather duster were used to create the snow effect as they are very light and can be easily moved with minimal airflow. We use four 5VDC fans to blow air into the capsule. These motors are powered via the 4 relay module. A relay module protects the microcontroller from overload and current spikes when starting. A 16x16 RGB LED matrix is ​​used for the light displays. By changing the sketch, images can also be displayed. A combination of MP3 player, amplifier and two speakers is used for the sound. To simulate the interior lighting of the houses in the village, 6 white 3mm LEDs are used, each of which must be connected to a 330 ohm resistor to adjust the supply voltage. The AZ-ATmega328 microcontroller was used to control all electronics.

 

Project assembly

   The figures and the structure were made of 3 millimeters thick balsa wood, as this material allows all the necessary changes to the structure to correct the project and is also very light and easy to handle. The dimensions of the figures and structure of this project are indicative and can be adjusted to the desired dimensions.

   To build the train, two drawings of each carriage and locomotive were glued from balsa wood and their outlines were cut out. In order to be able to place the train on the ring, it was decided to glue a wire between the two parts of each train figure. This was done by straightening a paper clip to attach the two parts of the figure and making a 1mm deep notch in each part of the figure so that the wire would stay in place when gluing the two parts together. The dimensions and method of manufacturing the train can be seen in the photo below.

 

Figure 1 – Dimensions and structure of the train

 

   It has already been mentioned that some houses in the village will have interior lighting. For this purpose, white LEDs will be installed in six houses. To build the village, the same method is used as for the train: the silhouettes of the houses to be glued are drawn. but before that, the outlines are cut out, the grooves are created for the installation of the LEDs and the connecting cables and the holes for the windows and doors are drilled so that the light from the LEDs shines through the paper when the outlines of the houses are glued. The dimensions of the houses can be freely adjusted.

 

Image 2 – City

 

   The method of building the Santa Claus figure is similar to that of the train: the outlines of the Santa Claus figure and the reindeer are marked, this time Santa Claus and the reindeer are connected by two wires, which are attached in a similar way to the train cars. The wire that connects Santa to the motor that turns him is attached to the back of the sleigh and then bent at a right angle to guide it to the motor axle.

 

Image 3 – Dimensions of Santa Claus

 

   The method for building the Christmas tree figures is similar to the previous ones: the outlines of the Christmas tree figures are marked and the figures are glued. You can use two outlines and connect them together or just use one wooden outline and stick the drawing of the Christmas tree on both sides.

Picture 4 – Christmas trees

 

   To assemble the train on the ring, the necessary grooves are made in the central area between the two edges of the rings, in order to subsequently form two 90 degree angles on the wires of the wagons and the locomotive and install them on the rings. The pictures show the dimensions of the ring, the shape given to the wires to incorporate the pull into the ring and the final state of the ring.

 

Figure 5 – Pull ring

 

   To build the platform on which the village will stand, a circle is cut out, the diameter of which must be slightly larger than the inner diameter of the ring. As can be seen in the images below, holes will be made to pass the connecting cables to the LEDs that will illuminate the interior of the village's houses, as well as three slots to insert the upper part of the columns that will attach the village's platform to the structure of the project. These columns are the same height as the exterior columns of the project box. On the inside of the platform, 3 wooden pins are placed so that they are inside the ring and have a clearance of about 2 millimeters so that the ring can rotate freely and they serve as a limit for possible lateral displacement of the ring.

 

Image 6 – City train platform

 

   In order to accommodate the fans, the fir trees and the motor that will rotate the ring of the train, it was planned to make a cube with a circle at the top with a diameter smaller than the outer diameter of the ring, thus keeping the ring containing the train within the limits of the platform of the village and the platform of the fans and fir trees. The train travels through the approximately 4 millimeter wide free gap. This project used columns that are the same height as the supporting columns of the village platform. There were three per side (on the edges  and in the middle of the pages). The reader can also use columns or plates of the required dimensions to cover them. The following figure shows the dimensions of all parts of this component.

 

Figure 7 – Fan platform

 

   The following pictures show the steps for assembling the first part of the project, which involves installing the village platform, the pull ring and the platform with the fans and fir trees. As you can see in the last picture, everything was painted with a white felt-tip pen to simulate a snowy landscape.

 

Image 8 – Assembly of the first part of the project

 

Description of how the first part of the project works and sketch

   For this first part of the project, the basic electronics for the movement of the train and Santa Claus were installed, as well as the interior lighting of some houses, 6 houses to be precise. The electronic circuit is structured as follows:

 

Drawing 1 – Snow Cube Drawing Part 1

 

   The circuit of the first part of the project has the L298N motor control module to control the speed and direction of rotation of the two motors of the assembly, one of which is responsible for moving the ring with the train and the other for moving Santa Claus. This module is supplied with two voltages: the control electronics of the module are supplied via the 5 VDC output of the microcontroller module, and the motors are supplied via an external 5 volt power supply. Care must be taken to remove the jumper that deactivates the module's internal controller.

 

Figure 9 – L298N Module

 

   There are 6 white 3 millimeter LEDs that must have a 330 ohm resistor connected to the positive terminal of each LED. This resistor regulates the voltage required to power the LED without destroying it due to overvoltage. The LEDs will be installed in 6 houses as interior lighting.

   Now the sketch from the first part will be analyzed. First, the pins of the microcontroller must be defined in the sketch to which the contacts of the L298N module that controls each motor will be connected. For each motor we need three ports, one controlling the motor speed and the other two controlling the direction of rotation. This defines six constants that are assigned the number of the port of the microcontroller to which the ENA, IN1, IN2, IN3, IN4 and ENB pins of the L298N module are connected. The names of the constants are easy to interpret which engines they represent.

 

#define enable_Santa_motor 7

#define connection_1_Santa_motor 5

#define connection_2_Santa_motor 6

 

#define enable_train_motor 2

#define connection_1_train_motor 3

#define connection_2_train_motor 4

 

   In addition, constants must be defined for the six LEDs, which will be assigned the number of the port of the microcontroller to which they will be connected.

 

#define led_house_1 8

#define led_house_2 9

#define led_house_3 10

#define led_house_4 11

#define led_house_5 12

#define led_house_6 13          

 

   With the definitions of the constants, the block for defining the variables and the method are completed setup() of the sketch must be programmed. First, the pins of the microcontroller that will be used to control the motors are configured. You have to come with me pinMode(pin_number, OUTPUT) configured as output signal pins because they need to send signals to the L298N control module pins.

 

pinMode(enable_Santa_motor,OUTPUT);

pinMode(connection_1_Santa_motor,OUTPUT);

pinMode(connection_2_Santa_motor,OUTPUT);

 

pinMode(enable_train_motor,OUTPUT);

pinMode(connection_1_train_motor,OUTPUT);

pinMode(connection_2_train_motor,OUTPUT);

 

   The microcontroller pins to which the LEDs are connected must also be configured as output pins, as they must supply voltage for the LEDs to light.

 

 

pinMode(led_house_1,OUTPUT);

pinMode(led_house_2,OUTPUT);

pinMode(led_house_3,OUTPUT);

pinMode(led_house_4,OUTPUT);

pinMode(led_house_5,OUTPUT);

pinMode(led_house_6,OUTPUT);

 

   The above lines are used to program the method setup() of the sketch completed. Now the method must loop() programmed to run continuously. The first three lines of this method are used to control Santa's engine, with the line analogWrite(pin_number, value)  The engine speed is set with an analog value whose maximum value is 244. As can be seen in the video of this first part, the engine speed is too high. If the value of this variable is less than 128, the motor will not rotate. The second part of the project solves this problem by adding a potentiometer. The two are used for the direction of rotation of the motor digitalWrite(pin_number, state) defined lines are used. If Santa's motor rotates in the opposite direction to the desired direction, this can be corrected either by changing the status of these two wires or by swapping the cables from the L298N module to the motor.

 

analogWrite(enable_Santa_motor,128);

digitalWrite(connection_1_Santa_motor,HIGH);

digitalWrite(connection_2_Santa_motor,LOW);

 

   The lines of code for controlling the pull ring motor are exactly the same as those explained previously. In this case the speed of the train is correct. If you want higher speed, you need to set the value in the line analogWrite(pin_number, value).

 

analogWrite(enable_train_motor,128);

digitalWrite(connection_1_train_motor,HIGH);

digitalWrite(connection_2_train_motor,LOW);

 

   In order for the LEDs to light, the status of the pins to which they are connected must be changed. Normally, when power is applied to a microcontroller board or reset, the initial status of the ports is low (LOW), That is, they do not supply any voltage, so the status is “high” (HIGH) must be changed to obtain an output voltage of 5 Vdc. This is done with the command digitalWrite(pin_number, STATE). There will be a 3 second pause after each LED turns on.

 

digitalWrite(led_house_1, HIGH);

delay(3000);

digitalWrite(led_house_2, HIGH);

delay(3000);

digitalWrite(led_house_3, HIGH);

delay(3000);

digitalWrite(led_house_4, HIGH);

delay(3000);

digitalWrite(led_house_5, HIGH);

delay(3000);

digitalWrite(led_house_6, HIGH);

delay(3000);

 

 

   We hope you enjoyed this first part of the project for Christmas this year. The second part of the project will install a WS2812B panel with 256 LEDs, a sound system and fans to simulate snow.

Für arduinoGrundlagen elektronikProjekte für fortgeschritteneRelaisSpecials

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