Incredibly spectacular color music using Arduino and LEDs. Incredibly spectacular color music on Arduino and LEDs Lighting effects on arduino


Attention! The new program is not compatible with old sketches.

Appearance of the new CMU program

The program supports color-musical and dynamic operating modes.
In color music mode, the outputs of 19 digital bandpass filters are used to generate color effects. The output values ​​of digital filters are transmitted at a constant rate by a personal computer and are contained in the readData array.
In dynamic mode, color effects are performed at a pace set by a programmable delay. No connection to a PC is required to run dynamic programs.
In the program you can choose one of 4 color and music programs or one of 8 dynamic ones. Not all programs are implemented in the attached tape controller sketch. I implemented 3 color-musical and 4 dynamic subroutines. You can create the rest of the programs yourself.

Color music programs:
Rainbow;
MIX;
I-beam;
The new one is left for your implementation.

Dynamic programs:
1 - theaterChaseRainbow - from examples for the Adafruit_NeoPixel library, the tempo is set by the slider;
2 - rainbowCycle - from examples for the Adafruit_NeoPixel library, the pace is set by the slider;
3 - flickering lights
4, 5, 6 - different options for running lights
7..8 - left for your implementation.

Setting the color of the entire tape is done by selecting a color in the color field;

Dynamic programs can be executed autonomously, without connecting to a PC. If you want to use the tape controller standalone, you will need to connect buttons to one or more digital inputs of the arduino board, and a potentiometer to one of the analog inputs. The buttons will be used to switch the program number, and the potentiometer will be used to change the program parameter (tempo, brightness, color). Connecting buttons and potentiometer to arduino can be found in standard examples. Write and add code to the tape controller sketch that changes the subroutine number prog and parameter values param, depending on the buttons pressed and the position of the potentiometer. You can use the IR receiver and the TV remote control to switch dynamic programs. Connecting an IR receiver to arduino can also be found in standard examples.

To implement color music programs you have the outputs of 19 bandpass filters. You can process them as you wish to obtain a beautiful color and music program. You can increase the number of programs using the parameter change slider (250 states) to change the color program.

Leave the code of your beautiful dynamic and color-musical routines in the comments to the article, so that anyone who likes it can add it to their sketch.

Create, invent, write, share and everyone can make the device they want.

Sketch for the computer connection option “COMtoLED.ino”:

Additional Information

#include #define ledPin 13 // LED on the arduino board #define stripPin 2 // LED strip control output #define stripLed 60 // number of LEDs in the strip #define bandPass 15 // number of CMU strips (LEDs used) #define ledDist 4 #define LedtoColor 4 // Parameter 1 = number of pixels in strip // Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/ WS2812 LEDs) // NEO_KHZ400 400 KHz (classic "v1" (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels , not v2) Adafruit_NeoPixel strip = Adafruit_NeoPixel(stripLed, stripPin, NEO_GRB + NEO_KHZ800); const uint32_t PROGMEM colorTab=( 0xFF0000,0xFF1100,0xFF2200,0xFF3300,0xFF4400,0xFF5500,0xFF6600,0xFF7700,0xFF8800,0xFF9900,0xFFAA00,0xFFBB00,0xFFCC00,0xFFDD00 ,0xFFEE00,0xFFFF00, //red - yellow 0xFFFF00,0xEEFF00,0xDDFF00,0xCCFF00 ,0xBBFF00,0xAAFF00,0x99FF00,0x88FF00,0x77FF00,0x66FF00,0x55FF00,0x44FF00,0x33FF00,0x22FF00,0x11FF00,0x00FF00, //yellow - green 0x00FF00,0x00FF11,0x 00FF22.0x00FF33.0x00FF44.0x00FF55.0x00FF66.0x00FF77.0x00FF88.0x00FF99, 0x00FFAA,0x00FFBB,0x00FFCC,0x00FFDD,0x00FFEE,0x00FFFF, //green - cyan (blue) 0x00FFFF,0x00EEFF,0x00DDFF,0x00CCFF,0x00BBFF,0x00AAFF,0x0099FF,0x0088FF,0x0077FF,0x 0066FF,0x0055FF,0x0044FF,0x0033FF,0x0022FF,0x0011FF, 0x0000FF, //blue - blue 0x0000FF,0x1100FF,0x2200FF,0x3300FF,0x4400FF,0x5500FF,0x6600FF,0x7700FF,0x8800FF,0x9900FF,0xAA00FF,0xBB00FF,0xCC00FF,0xDD00FF, 0xEE00FF,0xFF00FF, //blue - purple (magenta) 0xFF00FF,0xFF00EE ,0xFF00DD,0xFF00CC,0xFF00BB,0xFF00AA,0xFF0099,0xFF0088,0xFF0077,0xFF0066,0xFF0055,0xFF0044,0xFF0033,0xFF0022,0xFF0011,0xFF0000); //magenta - red typedef union( struct ( uint8_t b,g,r,w; ); uint32_t dw; ) TColor; typedef union( struct ( uint8_t b0,b1; ); uint16_t w; ) TWord; uint8_t inCounter = 0; boolean stringComplete = false; // whether the string is complete char prog = "4"; uint8_t param = 10; char inStr; // a string to hold incoming data char readData; // a string to hold incoming data void setup() ( // initialize serial: strip.begin(); strip.show(); // Initialize all pixels to "off" Serial.begin(115200); // reserve 32 bytes for the inputString: pinMode(ledPin, OUTPUT); ) void loop() ( // print the string when a newline arrives: if (stringComplete) ( stringComplete = false; cmdExecute(); readData=0; Serial.println(readData ); // Confirmation - the command is executed ) else ( switch (prog) ( case "3": ( theaterChaseRainbow(param); break; ) case "4": ( rainbowCycle(param); break; ) case "5": ( sub1(param); break; ) case "6": ( sub2(param); break; ) // case "7": ( sub3(param); break; ) // case "8": ( sub4(param) ; break; ) ) ) ) void cmdExecute() ( prog = readData; param = readData; switch (prog) ( case "r": ( zmu(); break; ) case "s": ( zmu2(); break; ) case "t": ( zmu3(); break; ) case "u": ( zmu4(); break; ) case "1": ( white(param); break; ) case "2": ( color(param ); break; ) case "3": ( theaterChaseRainbow(param); break; ) case "4": ( rainbowCycle(param); break; ) case "5": ( sub1(param); break; ) case "6": ( sub2(param); break; ) // case "7": ( sub3(param); break; ) // case "8": ( sub4(param); break; ) case "c": ( strip.clear(); strip.show(); break; ) ) ) void sub1 (uint8_t wait) ( // Write your code ) void sub2(uint8_t wait) ( // Write your code ) void zmu4() ( TColor cl; TWord akk; uint8_t i,k; for(i=0; i

Sketches for the wireless option:
Sketch for the module connected to a computer “COMtoRF.ino”:

Additional Information

#include // Connect the library to work with nRF24L01+ RF24 radio(9, 10); // Create a radio object to work with the RF24 library, indicating the pin numbers nRF24L01+ (CE, CSN) char rfData; // Create an array for data transfer uint8_t rfCounter = 0; char serData; // a string to hold incoming data uint8_t serCounter = 0; boolean stringComplete = false; void setup())( Serial.begin(115200); radio.begin(); // Initiate the work nRF24L01+ radio.setChannel(5); // Specify the data transmission channel (from 0 to 127), 5 means data is transmitted to frequency 2.405 GHz (on one channel there can be only 1 receiver and up to 6 transmitters) radio.setDataRate (RF24_1MBPS); // Specify the data transfer rate (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS), RF24_1MBPS - 1Mbit/s radio.setPALevel (RF24_PA_HIGH); // Indicate the transmitter power (RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBm, RF24_PA_MAX=0dBm) radio.openWritingPipe (0x1234567890LL); // Open a pipe with identifier 0x1234567890 for data transmission (on the channel can be open up to 6 different pipes, which should differ only in the last byte of the identifier) ​​) void loop())( uint8_t i; if (rfCounter>0) ( radio.write(&rfData,22); rfCounter=0; Serial.write(rfData,22); ) ) // SerialEvent void serialEvent() ( uint8_t i; while (Serial.available()) ( // get the new byte: char inChar = (char)Serial.read(); if (inChar != char(254)) ( if (inChar == char(255)) ( for(i=0; i<22; i++) rfData[i]=serData[i]; rfCounter = 22; serCounter = 0; // clear the input string: } else { serData = inChar; serCounter &= 0x1F; } } else serCounter = 0; // clear the input string: } }

Sketch for the “RFtoLED.ino” tape module:
#include // Include the library for working with the SPI bus #include // Include the settings file from the RF24 library #include // Include the library to work with nRF24L01+ #include #define stripLed 120 // number of LEDs in the strip #define bandPass 17 // stripes (groups of LEDs) #define stripPin 2 // LED strip control output #define ledDist 7 #define LedtoColor 7 // Parameter 1 = number of pixels in strip / / Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic "v1 " (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) Adafruit_NeoPixel strip = Adafruit_NeoPixel(stripLed, stripPin , NEO_GRB + NEO_KHZ800); RF24 radio(9, 10); // Create a radio object to work with the RF24 library, indicating the pin numbers nRF24L01+ (CE, CSN) const uint32_t PROGMEM colorTab=( 0xFF0000,0xFF1100,0xFF2200,0xFF3300,0xFF4400,0xFF5500,0xFF6600,0xFF7700,0xFF8800,0x FF9900.0xFFAA00.0xFFBB00, 0xFFCC00,0xFFDD00,0xFFEE00,0xFFFF00, //red - yellow 0xFFFF00,0xEEFF00,0xDDFF00,0xCCFF00,0xBBFF00,0xAAFF00,0x99FF00,0x88FF00,0x77FF00,0x66FF00,0x55FF00,0x44FF 00,0x33FF00,0x22FF00,0x11FF00,0x00FF00, //yellow - green 0x00FF00,0x00FF11,0x00FF22,0x00FF33,0x00FF44,0x00FF55,0x00FF66,0x00FF77,0x00FF88,0x00FF99,0x00FFAA,0x00FFBB,0x00FFCC,0x00FFDD,0x00FFEE,0x00FFFF, // green - cyan (blue) 0x00FFFF,0x00EEFF,0x00DDFF,0x00CCFF,0x00BBFF, 0x00AAFF,0x0099FF,0x0088FF,0x0077FF,0x0066FF,0x0055FF,0x0044FF,0x0033FF,0x0022FF,0x0011FF,0x0000FF, //blue - blue 0x0000FF,0x1100FF,0x2200FF,0x330 0FF,0x4400FF,0x5500FF,0x6600FF,0x7700FF,0x8800FF,0x9900FF,0xAA00FF,0xBB00FF ,0xCC00FF,0xDD00FF,0xEE00FF,0xFF00FF, //blue - purple (magenta) 0xFF00FF,0xFF00EE,0xFF00DD,0xFF00CC,0xFF00BB,0xFF00AA,0xFF0099,0xFF0088,0xFF0077,0xFF0066,0xFF0055 ,0xFF0044,0xFF0033,0xFF0022,0xFF0011,0xFF0000); //magenta - red typedef union( struct ( uint8_t b,g,r,w; ); uint32_t dw; ) TColor; typedef union( struct ( uint8_t b0,b1; ); uint16_t w; ) TWord; char readData; // Command buffer char prog = "3"; uint8_t param = 0; void setup())( // initialize serial: Serial.begin(115200); strip.begin(); strip.show(); // Initialize all pixels to "off" radio.begin(); // Initiate work nRF24L01+ / / radio.setAutoAck(false); radio.setChannel(5); // Specify the data reception channel (from 0 to 127), 5 means data is received at a frequency of 2.405 GHz (there can be only 1 receiver on one channel and up to 6 transmitters) radio.setDataRate (RF24_1MBPS); // Specify the data transfer rate (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS), RF24_1MBPS - 1Mbit/s radio.setPALevel (RF24_PA_HIGH); // Specify the transmitter power (RF24_PA_MIN=-18dBm, RF24_PA_LOW=-1 2dBm , RF24_PA_HIGH=-6dBm, RF24_PA_MAX=0dBm) radio.openReadingPipe (1, 0x1234567890LL); // Open 1 pipe with identifier 0x1234567890 to receive data (up to 6 different pipes can be opened on the same channel, which should differ only in the last byte of the identifier) radio.startListening (); // Turn on the receiver, start listening to open pipes) void loop())( if(radio.available())( // If there are received data in the buffer, then we get the number of the pipe through which they came, by reference to the variable pipe radio.read(&readData, 22); // Receive the command cmdExecute(); ) else ( switch (prog) ( case "3": ( theaterChaseRainbow(param); break; ) case "4": ( rainbowCycle(param); break; ) case "5": ( sub1(param); break; ) case "6": ( sub2(param); break; ) // case "7": ( sub3(param); break; ) // case "8": ( sub4(param); break; ) ) ) ) void cmdExecute() ( prog = readData; param = readData; switch (prog) ( case "r": ( zmu(); break; ) case "s": ( zmu2(); break; ) case "t": ( zmu3 (); break; ) case "u": ( zmu4(); break; ) case "1": ( white(param); break; ) case "2": ( color(param); break; ) case "3 ": ( theaterChaseRainbow(param); break; ) case "4": ( rainbowCycle(param); break; ) case "5": ( sub1(param); break; ) case "6": ( sub2(param); break; ) // case "7": ( sub3(param); break; ) // case "8": ( sub4(param); break; ) case "c": ( strip.clear(); strip.show (); break; ) ) ) void sub1(uint8_t wait) ( // Write your code ) void sub2(uint8_t wait) ( // Write your code ) void zmu4() ( TColor cl; uint8_t i,k; for(i =0;i 95) colorNumber=95; cl.dw = pgm_read_dword(&colorTab); cl.dw = strip.Color(cl.r, cl.g, cl.b); for(i=0; i


Operation of the Rainbow, MIX, I-beam programs:






Add to favorites Liked +65 +147

On the Internet I found a lot of interesting ideas on how to simulate the effect of fire using programmable LEDs WS2812c and Arduino. I tried to make my own night light that will add romance to the room.

Each instruction used a different combination of LED types and microcontrollers for them. They all had various disadvantages, such as how big a fire lamp could be, what it was designed for, etc. You will see my result below. Like any of my projects, I don’t want to call it completed, because looking at it, every time I discover new things that can be improved or refined.

Step 1: Create the Electronics


For the project you need:

  1. LED strip WS2812b with LEDs located very close to each other. You can use other LEDs, for example, if you want to create a taller floor lamp simulating a flame, instead of a table lamp.
  2. Arduino nano. For me this module was quite enough. If you want to make a more complex thing, then other types of boards will work better
  3. Wires for connection

Since the diodes and Arduino nano use 5V, I was locked to that voltage. This means that you can use a power bank to power the lamp and create a romantic atmosphere anywhere, anytime.

My LED strip had 120 diodes, I divided it into strips of 20 diodes per cylinder, you can see this in the photo. I also soldered the male/female plugs so that I could replace some parts of the lamp in the future.

To program the LEDs I used the NeoPixel library. I also used parts of the code found on the internet, which I modified a lot to adapt and give the glow a more realistic feel.

Step 2: Lighting Effects

So, having finished with the electronics, we see that the glow still doesn't look like fire. To add realism, we need to scatter the light from the diodes, so that the glow of each individual diode is no longer distinguishable.

After experimenting a bit with paper (which diffused the light too much) and plastic film painted white (also not suitable for my needs), I came to the conclusion that the only viable solution was to use frosted glass or acrylic.

Since I wanted to use the simulated fire lamp a lot, I decided to just buy a regular lamp and use it as a shell.

I removed all the electronics from the lamp and replaced it with my own. The glass of the lamp gave a pleasant diffusing effect, so a couple of tweaks and modifications to the program code made me completely satisfied with the result.

With coming! The New Year is approaching, which means it’s time to urgently create the mood! Well, as always, at this time of year, dozens of electronic circuits of various color and music installations are born.

What unique masters can’t come up with. From three-color blinkers to multi-beam laser systems controlled via a MIDI interface.

As a big fan of the so-called addressable LEDs, I want to show you a very simple and amazing color music. I've never seen anything like this before. Until I assembled it in one evening. So, sound visualizer!

Instructions

The scheme is very simple!


You will need an Arduino Nano, or Uno. Or which one do you have? Two potentiometers, five resistors, a pair of capacitors and a line (strip) of 180 WS2812b LEDs. All! There can be 60, 120 or 180 LEDs in the line.

In the visualizer, using the fast Fourier transform algorithm, 8 frequencies are selected (the sensitivity threshold for each frequency is different, decreasing from 1 to 8), converted to color and displayed on a line of LEDs using one of eight algorithms. The sketch was written by Michael Krampas, the guys from Chip and Deep added functionality, and the library for LEDs and fast Fourier transform (FFT) was written in Adafruit for the Piccolo project. The FFT library for 128 points, adapted for AVR microcontrollers, is written in assembler.

The sketch itself and the FFT library need to be downloaded and .

Don't waste time analyzing algorithms, just assemble, upload a sketch and enjoy the show.
It's just entertainment!

When you turn it on for the first time, you need to do a couple of settings:

Brightness: hold color button when power on. The first 8 LEDs will display a rainbow of LEDs. Use the param knob to change the brightness. When finished, press the color button again and your configuration will be saved into memory.

LED strip length: hold down the pattern button when turning on the power. One, two or three red LEDs will be displayed. Use the param knob to select the length of the LED strip depending on the number of red LEDs:

1=60 LEDs
2=120 LEDs
3=180 LEDs

When finished, press the pattern button again and your configuration will be saved into memory.

Algorithms

Dancing plus: audio peaks are emitted from the center of the strip and disappear as they approach the ends. The speed of the peak is proportional to the magnitude of the audio signal of that peak.

Dancing minus: same as Dance Party, but the signal spikes are emitted from one end.
Pulse: Signal peaks appear as bright pulses that come from the center of the strip. The pulse width depends on the signal level.

Light strip: the entire strip is illuminated in peaks.

Color stripes: Signal peaks appear as colored bars that disappear.

Color stripes 2: similar to colored stripes, but each stripe shrinks and disappears.

Flashes: Signal peaks are displayed as an LED flash at a random location. The initial color is white and then fades through another color.

Fireflies: signal peaks appear as single LEDs in a random location, and they move left or right and disappear. Their speed depends on the size of the signal.

Color schemes

Random two-color scheme: two random colors are selected and only these are used to display signal peaks. Over time, new colors will be selected. Use param to adjust how quickly the color scheme changes. If the "parameters" potentiometer knob is in the up position, the colors will change frequently and each signal peak will have a new color. I recommend installing the handle in the middle.

Rainbow: All signal peaks appear as the same color (with a small amount of random variation) and this color changes like a rainbow over time. The speed of color change is set by the param potentiometer.

Colored Frequencies: In this mode, each signal peak is colored depending on the frequency band where it is located. The lowest band is red, and further up the spectrum. There are 8 frequency bands: red, orange, yellow, green, cyan, indigo, violet, white. This color mode is most interesting when the frequency response is set to all frequency bands.

Frequency range: you can control the frequency range to which color music responds. To set the range, press and hold both buttons. Use the param knob to select how many of the eight frequency ranges will be shown. If you want to highlight the bass and rhythm of the music, set the frequency response to only the lowest 2 or 3 bands. If you want to show all frequencies in the music (such as vocals and higher instruments), select all frequency bands.

This is a video instruction for setting up and also a demonstration of the visualizer in operation. There are two musical compositions at the end with different algorithms.

One more composition

Guys! And ladies of course. I really want you to have time to make this simple design for the New Year holiday. You will not regret! Guests will be shocked!

Happy New Year 2018!

Added 12/15/2017 Epilogue or debriefing
1. How to change the backlight during pauses?
2. Is it possible to change the dynamics?
3. How to connect a strip with a number of LEDs other than 60/120/180?
Plus an updated scheme has been published. Don't worry, we only added one resistor.
There are two weeks left until the New Year. Will you have time to collect?

Added 06/09/2018
Made the backlight settings:
sketch and diagram.
Let's use it like this.
Background lighting:
During pauses, the background lighting is turned on, i.e. the entire line will glow in the color you choose and with the selected brightness.
Color: Set the PARAM2 potentiometer to the middle position and press the Background button once. The LED bar will light up. Rotate the PARAM2 potentiometer, the color of the ruler will change from red to purple. Select a color and click the Background button again.
Brightness: Set the potentiometer to the minimum position (knob all the way clockwise) and press the Background button. The line will go out. Slowly rotate the PARAM2 potentiometer knob to select the desired backlight brightness and press the Background button again. The brightness values ​​will be written to the microcontroller memory.

  • Price: $8.69
  • “What is New Year without a Christmas tree?”

    Your toys are defective! - What, they don’t shine? - No, they are not happy!

    Probably everyone is already tired of boring garlands with the same type of effects. I want something more serious, with a minimum of investment and use of my head (it already hurts from the New Year's chaos).

    Here we will consider a garland with 100 LEDs, with 1000 variations and a price of 150 rubles per controller

    My wishes:

    Use the tape on the WS2811, and so that it is controlled by the remote control. On Arduino, as a rule, this is not feasible, it is rather weak, there are not enough resources, you cannot attach anything extra.

    I was already ready to build this on ARM controllers. (I have a lot of controller boards with LPC1754 lying around) but I don’t want to solder, and I don’t have time to translate the code from Arduino.

    Yes, I know what can be done on the ESP8266, but I don’t want to... (those who wish can port the sketch themselves)

    And while painfully scouring the Internet in search of interesting effects for different libraries, I accidentally came across the FastLED-Demos page, where Andrew Tuline uploads effects for the FastLED library.

    I'm interested in the notamesh section

    I said Wow... and away we go...

    So.

    To repeat the pattern:

    Buy a garland based on WS2811 or WS2812 or the like (probably purchased a long time ago at previous sales).

    Buy an Arduino UNO, NANO or similar module on an ATMega328 controller

    Take an IR module (this or that)

    A remote control for an old TV or VCR or player.

    Power supply 5 volts and 3 amps. Well, anyone

    I had 100 pieces of WS2812B, I rolled each LED in transparent heat shrink, this gave a 360 degree glow.

    Images

    In the bins there was a scarf with a NANO circuit, a power supply, an IR receiver, and the housing from the router connected it all together.

    Images

    I managed:

    input from IR pin 8 (PB0, D8, physical pin 12),

    output to garland pin 14 (PC0, A0, physical pin 23)

    Here's the diagram:

    Check the pinout (for example, IR receivers may have different pinouts)

    You can choose other Arduino legs, I will show you where to change in the sketch.

    Now about the sketch

    I left the first one, replaced the second one with IRremote (https://github.com/z3t0/Arduino-IRremote), now the remote control works with the FastLED library.

    My version of the sketch with these libraries https://yadi.sk/d/4aKV_Ug6HcFdWQ

    I tried not to redo the original sketch (no time).

    I will add new teams in the future.

    Let's continue

    Download the FastLED and IRremote libraries and install them.

    To install the IRremote library, according to the author's advice, you need to remove Arduino/libraries/RobotIRremote

    We take the remote control, load an example from the IRremote library called IRrecvDemo

    In line 11 int RECV_PIN = 11; 11 is changed to 8 (in my circuit an IR receiver is connected to this pin)

    Upload the sketch to Arduino.

    We press the buttons on the remote control and codes will appear in port monitor mode, remember them.

    These codes must be inserted into the file commands.h,

    For example:

    for the team IR_A1(increase brightness) I have a key code on my remote control 0xff4ab5

    #define IR_A1 0xff4ab5 //N/P //Increasing brightness of A1

    you'll figure it out, I think.

    Setting up my sketch

    In line 75 we set the pin of the IR receiver int RECV_PIN = 8;

    In line 84 we set the output pin for the garland #define LED_DT 14

    If you have other garlands, then select its type in lines 84-87.

    And don’t forget to remove the comment in line 208 for 4 wired garlands and add it to 209

    //LEDS.addLeds (leds, MAX_LEDS);

    LEDS.addLeds (leds, MAX_LEDS);

    If the pins are not mixed up, it should work right away

    At the first start, the number of LEDs in the garland is set to 20 pcs.

    Therefore, for those who do not use the remote control, you need to put the required number of LEDs in drain 119,

    #define INITLEN 20

    and if you have already launched, then change the code in line 225

    NUM_LEDS = EEPROM.read(STRANDLEN);

    On NUM_LEDS =100;

    Where 100 is your number of LEDs.

    For others, the number of LEDs can be adjusted from the remote control

    I am not limited by the current of the power supply, if your power supply is weaker,

    then in line 211 we change the second number to yours

    set_max_power_in_volts_and_milliamps(5, 3000);

    where 3000 is the maximum current of the power supply in mA, we change it if necessary

    Look like that's it

    When I have time, I’ll add effects and post the sketch here.

    I recorded video effects (demonstration mode)

    And in the video, without changing the effect, I switched palettes with the remote control.

With coming! The New Year is approaching, which means it’s time to urgently create the mood! Well, as always, at this time of year, dozens of electronic circuits of various color and music installations are born.

What unique masters can’t come up with. From three-color blinkers to multi-beam laser systems controlled via a MIDI interface.

As a big fan of the so-called addressable LEDs, I want to show you a very simple and amazing color music. I've never seen anything like this before. Until I assembled it in one evening. So, sound visualizer!

Instructions

The scheme is very simple!


You will need an Arduino Nano, or Uno. Or which one do you have? Two potentiometers, five resistors, a pair of capacitors and a line (strip) of 180 WS2812b LEDs. All! There can be 60, 120 or 180 LEDs in the line.

In the visualizer, using the fast Fourier transform algorithm, 8 frequencies are selected (the sensitivity threshold for each frequency is different, decreasing from 1 to 8), converted to color and displayed on a line of LEDs using one of eight algorithms. The sketch was written by Michael Krampas, the guys from Chip and Deep added functionality, and the library for LEDs and fast Fourier transform (FFT) was written in Adafruit for the Piccolo project. The FFT library for 128 points, adapted for AVR microcontrollers, is written in assembler.

The sketch itself and the FFT library need to be downloaded and .

Don't waste time analyzing algorithms, just assemble, upload a sketch and enjoy the show.
It's just entertainment!

When you turn it on for the first time, you need to do a couple of settings:

Brightness: hold color button when power on. The first 8 LEDs will display a rainbow of LEDs. Use the param knob to change the brightness. When finished, press the color button again and your configuration will be saved into memory.

LED strip length: hold down the pattern button when turning on the power. One, two or three red LEDs will be displayed. Use the param knob to select the length of the LED strip depending on the number of red LEDs:

1=60 LEDs
2=120 LEDs
3=180 LEDs

When finished, press the pattern button again and your configuration will be saved into memory.

Algorithms

Dancing plus: audio peaks are emitted from the center of the strip and disappear as they approach the ends. The speed of the peak is proportional to the magnitude of the audio signal of that peak.

Dancing minus: same as Dance Party, but the signal spikes are emitted from one end.
Pulse: Signal peaks appear as bright pulses that come from the center of the strip. The pulse width depends on the signal level.

Light strip: the entire strip is illuminated in peaks.

Color stripes: Signal peaks appear as colored bars that disappear.

Color stripes 2: similar to colored stripes, but each stripe shrinks and disappears.

Flashes: Signal peaks are displayed as an LED flash at a random location. The initial color is white and then fades through another color.

Fireflies: signal peaks appear as single LEDs in a random location, and they move left or right and disappear. Their speed depends on the size of the signal.

Color schemes

Random two-color scheme: two random colors are selected and only these are used to display signal peaks. Over time, new colors will be selected. Use param to adjust how quickly the color scheme changes. If the "parameters" potentiometer knob is in the up position, the colors will change frequently and each signal peak will have a new color. I recommend installing the handle in the middle.

Rainbow: All signal peaks appear as the same color (with a small amount of random variation) and this color changes like a rainbow over time. The speed of color change is set by the param potentiometer.

Colored Frequencies: In this mode, each signal peak is colored depending on the frequency band where it is located. The lowest band is red, and further up the spectrum. There are 8 frequency bands: red, orange, yellow, green, cyan, indigo, violet, white. This color mode is most interesting when the frequency response is set to all frequency bands.

Frequency range: you can control the frequency range to which color music responds. To set the range, press and hold both buttons. Use the param knob to select how many of the eight frequency ranges will be shown. If you want to highlight the bass and rhythm of the music, set the frequency response to only the lowest 2 or 3 bands. If you want to show all frequencies in the music (such as vocals and higher instruments), select all frequency bands.

This is a video instruction for setting up and also a demonstration of the visualizer in operation. There are two musical compositions at the end with different algorithms.

One more composition

Guys! And ladies of course. I really want you to have time to make this simple design for the New Year holiday. You will not regret! Guests will be shocked!

Happy New Year 2018!

Added 12/15/2017 Epilogue or debriefing
1. How to change the backlight during pauses?
2. Is it possible to change the dynamics?
3. How to connect a strip with a number of LEDs other than 60/120/180?
Plus an updated scheme has been published. Don't worry, we only added one resistor.
There are two weeks left until the New Year. Will you have time to collect?

Added 06/09/2018
Made the backlight settings:
sketch and diagram.
Let's use it like this.
Background lighting:
During pauses, the background lighting is turned on, i.e. the entire line will glow in the color you choose and with the selected brightness.
Color: Set the PARAM2 potentiometer to the middle position and press the Background button once. The LED bar will light up. Rotate the PARAM2 potentiometer, the color of the ruler will change from red to purple. Select a color and click the Background button again.
Brightness: Set the potentiometer to the minimum position (knob all the way clockwise) and press the Background button. The line will go out. Slowly rotate the PARAM2 potentiometer knob to select the desired backlight brightness and press the Background button again. The brightness values ​​will be written to the microcontroller memory.







2024 gtavrl.ru.