📜 ⬆️ ⬇️

Lumiere Processing + Arduino + RGB

Prologue


New Year's holidays are long gone, it's time to get ready for the upcoming 2015 NG.
That is why I hasten to share the idea and implementation of light music (garlands) on Arduin and trimming RGB tapes.
The idea, as always, came on time 8 hours before NG. When decorating an apartment, I realized that I couldn’t decorate my room with the remnants of burnt garlands!
Yes, and ritual soldering grandfather-father and Chinese garlands already got. I wanted something new!

purpose


Connect RGB-tape to Arduino, and make it dance to your music from a computer.

Result




What do you need?


')


Tasks


1. Since the tape is 12V, we connect it to the Arduina pins (5V) by means of the Darlington transistor assembly ULN2003A (What happened, it happened!).
2. We glue the tape into a visible place and decorate it. Plain paper does wonders with light! I'm not talking about various types of plastic and glass.
3. Fill the Arduin sketch (see below) for processing SerialPort
4. Display the light music on SerialPort, in my case I used the Minim Processsing library. It would be possible to sit on Winamp / AIMP, but time was running out!
5. We adjust music so that nobody is sick. Or vice versa sick, if the music is appropriate!
6. We dance, meditate, meet NG!

Progress


1. The scheme is extremely simple, but you never know.

2. Scotch and paper have done their job! The light became even and pleasant, the design is simple and uncomplicated, even crookedly glued A4 sheets look great in the work!

3. The software part (there is a whole space for fantasy)

Sketches of Arduin and test sketches can be downloaded below.

Processing with "minim" library:
import ddf.minim.*; import ddf.minim.analysis.*; import processing.serial.*; Serial port; Minim minim; AudioPlayer song; BeatDetect beat; BeatListener bl; float kickSize, snareSize, hatSize; class BeatListener implements AudioListener { private BeatDetect beat; private AudioPlayer source; BeatListener(BeatDetect beat, AudioPlayer source) { this.source = source; this.source.addListener(this); this.beat = beat; } void samples(float[] samps) { beat.detect(source.mix); } void samples(float[] sampsL, float[] sampsR) { beat.detect(source.mix); } } void setup() { size(512, 200, P3D); minim = new Minim(this); println("Available serial ports:"); println(Serial.list()); // check on the output monitor wich port is available on your machine port = new Serial(this, Serial.list()[0], 9600); song = minim.loadFile("1.mp3", 2048); // ,     !          *.mp3 song.play(); // a beat detection object that is FREQ_ENERGY mode that // expects buffers the length of song's buffer size // and samples captured at songs's sample rate beat = new BeatDetect(song.bufferSize(), song.sampleRate()); // set the sensitivity to 300 milliseconds // After a beat has been detected, the algorithm will wait for 300 milliseconds // before allowing another beat to be reported. You can use this to dampen the // algorithm if it is giving too many false-positives. The default value is 10, // which is essentially no damping. If you try to set the sensitivity to a negative value, // an error will be reported and it will be set to 10 instead. beat.setSensitivity(300); kickSize = snareSize = hatSize = 0; // make a new beat listener, so that we won't miss any buffers for the analysis bl = new BeatListener(beat, song); textFont(createFont("Helvetica", 16)); textAlign(CENTER); } boolean k1,k2,k3; void draw() { float s=10; background(0); fill(255); if ( beat.isKick()) k1 = true; if ( beat.isSnare()) k2 = true; if ( beat.isHat()) k3 = true; // textSize(kickSize/8); // text("KICK", width/4, height/2); // textSize(snareSize/8); // text("SNARE", width/2, height/2); // textSize(hatSize/8); // text("HAT", 3*width/4, height/2); port.write('R'); port.write((int)kickSize); port.write('G'); port.write((int)snareSize); port.write('B'); port.write((int)hatSize); if (k1) kickSize = constrain(kickSize+5, 20, 255); else kickSize = constrain(kickSize -5, 20, 255); if (kickSize==255) k1=false; if (k2) snareSize = constrain(snareSize+15, 40, 255); else snareSize = constrain(snareSize-15, 40, 255); if (snareSize==255) k2=false; if (k3) hatSize = constrain(hatSize+s, 20, 255); else hatSize = constrain(hatSize-s, 20, 255); if (hatSize==255) k3=false; } 


Conclusion


This is how we make a festive holiday atmosphere and fun. I got it from scrap materials! For a target purchase, it would all cost $ 50 dollars.

Download files:

*** CLICKNESS HERE *** Archived sketch for Arduin, test sketch for RGB, and the program itself. The minim library weighs a lot and doesn’t fit in there, download and install it yourself.

Thanks for reading!

Source: https://habr.com/ru/post/214337/


All Articles