Power Supply

The power supply in this model is 24 volts and 3.5 watts. It is responsible for providing the necessary power to the controller and the LED series. The power supply is usually enclosed in the same casing as the controller, as is the case with this model.

Controller

The controller is the component responsible for changing the light effect by pressing the button. It is connected to the LED series with two wires. By reversing the direction of the power supply, the controller is able to invert the voltage across the LEDs, thus turning on the pairs of yellow-red and green-blue LEDs based on the chosen effect.

LED Series

The LED series is composed of four different colors. To make the connection easier to understand, one of the two wires is marked with some tape. When the power supply is connected in one direction, the yellow and red LEDs light up, while when it is connected in the other direction, the green and blue LEDs light up.

Oscilloscope

To check the output signal from the controller, an oscilloscope is used. The controller is found to be generating a square wave plus-minus 15 volts. The polarity changes with a frequency of 50 hertz, meaning the LEDs turn on and off 50 times per second, making them appear to be constantly on.

Understanding the Requirements

In order to replace the light controller with an Arduino, it is important to understand the requirements. Firstly, the circuit needs to be capable of handling a voltage of 24 volts and inverting it at the output. Secondly, the lights need to be controlled via a smartphone via WiFi. Lastly, a step down power supply is required to lower the power supply voltage to the 5 volts needed by the Mini S2 board and the h Bridge.

Choosing the Components

The components chosen for this project are an h Bridge based on the 298 integrated circuit, the Mini S2 board from wmos, and a step down power supply. The h Bridge is capable of handling a voltage of 24 volts and inverting it at the output. The Mini S2 board provides an esp32 S2 chip with WiFi and Bluetooth connectivity that can also be programmed with the Arduino IDE. The step down power supply is used to lower the power supply voltage to the 5 volts needed by the Mini S2 board and the h Bridge.

Wiring Everything Together

The power supply must be connected directly to a terminal block of the h Bridge. The 5 volt output from the step down module is used to power the Mini S2 board and the h Bridge to control the lights. Three signals are connected to the h Bridge: one to control the lights, one to control the waveform, and one to control the Arduino sketch. The lights are connected to the output of the h Bridge.

Programming the Arduino

The Arduino IDE is used to program the Arduino and control the lights. The code is written to control the lights, the waveform, and the Arduino sketch. The code is then uploaded to the Mini S2 board via the Arduino IDE. Once the code is uploaded, the lights can be controlled via the smartphone via WiFi.

The Three Pins of the Bridge

The three pins of the bridge are integral to controlling the direction of the output voltage. The two branches of the bridge are controlled by the in one and in two pins, while the n pin enables or disables the entire bridge. A simple sketch can be used to make the different pairs of LEDs flash every second, simply by keeping the bridge always active and changing the state of the in one and in two signals.

Varying the Brightness of LEDs

To create a flashing effect, a PWM signal must be applied to the n pin. By varying the duty cycle of the PWM signal, the time in which the LEDs remain on and the brightness perceived by our eyes can be changed. The AS32 chip includes a specific peripheral for generating PWM signals, known as LED Control (LEDC).

Initializing LEDC

The LEDC must be initialized with the LEDC setup method. This requires specifying the channel to be used, the frequency of the generated signal, and the resolution in bits. The resolution determines the number of different duty cycle values possible, with an 8-bit resolution allowing 256 different values and therefore 256 different brightness levels.

Attaching Pins to LEDC

Once the device has been configured, the pins to be used by the chosen channel must be indicated using the LEDC attach pin method. This ensures that the correct pins are used to control the LEDs and their associated brightness levels.

You can find the complete sketch that you can upload to your board.

Connecting the n PIN of the H-Bridge to Pin 16 of the Board

In our project, we connected the n PIN of the H-Bridge to pin 16 of the board. This pin will be passed as a parameter to the ledc right command in order to configure the required duty cycle value. With the oscilloscope, we can see that the signal generated from pin 16 is precisely at 5000 Hz with a duty cycle of 50. If different values for the duty cycle are tried, it can be observed that the brightness does not vary in a linear manner.

Gamma Correction

The human eye perceives variation in brightness better when it is close to dark compared to when it is high. To better manage the brightness for Arduino, gamma correction can be applied to the duty cycle values. There is a convenient library available which can be used to sketch without gamma correction on the left and the one with gamma correction on the right for the same duty cycle values of 50, 100 and 200.

Complete Project

The complete project can be found in the gitab repository. The link is provided in the description. The complete sketch can be uploaded to the board. The sketch contains the code for the gamma correction as well as the code for the LED lights.

Components Needed

To create a Christmas light display with Arduino, you will need a few components. First, you will need an Arduino board, such as an Uno or a Nano. You will also need a power supply, LED strips, and a water-tight enclosure. Additionally, you will need a WiFi module, such as an ESP-01, and a few other components to connect the LED strips to the Arduino.

Connecting the Components

Once you have all the components, you can begin connecting them. First, connect the Arduino to the power supply and the WiFi module. Then, connect the LED strips to the Arduino. Make sure to use a water-tight enclosure to protect the components from the elements.

Configuring the WiFi Module

Next, you will need to configure the WiFi module. To do this, you will need to use the example sketches provided by the manufacturer. These sketches will allow you to connect the board to your WiFi network. Once connected, you can access the board using a web browser.

Creating a Web Interface

Once the board is connected to your WiFi network, you can create a web interface to control the lights. To do this, you can use a library called ESP-UI. This library allows you to create a web interface without writing a single line of HTML code. With this interface, you can choose the type of effect and configure its parameters, such as the backlight frequency or the fading speed.

Saving the Configuration

Finally, you can use the preferences library to save the configuration. This library allows you to store the configuration in the non-volatile memory of the chip. This means that the configuration will be retained even if the board is turned off. With this, you can easily reset the configuration to its default values with the press of a button.

Christmas lights can be controlled with an Arduino by using an h Bridge based on the 298 integrated circuit, the Mini S2 board from wmos, and a step down power supply. The power supply is connected to the h Bridge, the 5 volt output is used to power the Mini S2 board and the h Bridge, and the lights are connected to the output of the h Bridge. The Arduino IDE is used to program the Arduino and control the lights. Once the code is uploaded, the lights can be controlled via the smartphone via WiFi.

Creating a Christmas light display with Arduino is a great way to add a festive touch to your home. With the right components and a bit of coding, you can create a beautiful display that can be controlled with a web interface. With this, you can easily customize the lights to your liking and create a unique holiday experience.

Share.
Exit mobile version