Introduction: Sync PixMob Wristband With Music
Note: if you want to see the original post in Spanish: El blog de Carlos Ganoza
This past year several concerts have been held again in my country after the restrictions on the celebration of mass events were lifted, and one of the things that attracted the most attention in these concerts was the use of LED bracelets among attendees, such bracelets we could see in concerts like Bad Bunny or Coldplay. Although it is really nothing new, PixMob, the company that manufactures them, has been marketing its products since 2010.
K-pop bands such as BTS have also been using the so-called Army Bombs in their concerts for a long time:
Still picking up your lighter? The future is now, old man!
In the case of the wristbands, they are handed out "free of charge" to the attendees, and once the show starts, they are synchronized to emit all the same colors in a harmonious way.
But how do they work?
I had the opportunity to attend Bad Bunny's concert and, upon entering, I was given this wristband:
A bracelet from the company PixMob:
At the end of the concert many of us were left with the desire to continue using them, so I started to investigate and this is what I discovered:
If we disassemble the bracelet we can see that it has an infrared receiver, two RGB LEDs and that they are powered by two 3V CR1632 batteries.
I have seen some projects on github linked to this bracelet, among them I found this repository by Daniel Weidman who through reverse engineering had obtained the color codes for the operation of the bracelet.
As you will see in the repository, the project is oriented to work with FliperZero, and to my bad luck, even though I bought one, it never arrived to me...
The good news is that I did have several development boards, including a NodeMCU(ESP8266), and I set out to make a device that controls these bracelets and that not only allows us to control the lights, but also to turn them on to the rhythm of the music.
Supplies
- KY-038 Sensor
- IR LED Emitter
- BC547 Transistor
- NodeMCU Board (ESP8266)
Step 1: We Assemble Everything As Follows:
We use the transistor as an amplifier for our infrared emitter, in this case I am using a BC547 but it could also be a 2n2222 or another NPN.
Through the base of the transistor, connected to pin D1, we will control the IR signals that our LED will emit (if we connect it directly the light will be very dim and will not work) and for this we also need to use the IRremoteESP8266 library.
Step 2: Open the Arduino IDE and Install the Library As Shown in the Image:
Tools > Library Manager. and install IRremoteESP8266 library
Step 3: We Create a New Sketch Where We Are Going to Import It in the Following Way:
#include <IRremoteESP8266.h>
#include <IRsend.h>
we continue to configure our pins:
const int IRLedPin = 5; // led GPIO pin
IRsend irsend(IRLedPin);
RLedPin = 5 refers to GPIO 5 which in NODEMCU is labeled as D1 as shown in the following
Step 4: We Define Some Colors Based on the Previously Shared Repository:
I chose these but you can use your lucky color:
uint16\_t yellow[21] = {1400, 1400, 700, 700, 700, 1400, 700, 2800, 700, 2100, 1400, 700, 700, 700, 700, 1400, 1400, 2800, 1400, 2800, 700};
uint16\_t blue[27] = {700, 700, 700, 2100, 1400, 700, 700, 2800, 700, 1400, 700, 700, 700, 1400, 1400, 700, 700, 1400, 700, 700, 700, 700, 700, 700, 700, 2100, 700};
uint16\_t green[21] = {1400, 1400, 700, 700, 700, 700, 1400, 2800, 700, 1400, 700, 1400, 700, 1400, 700, 1400, 1400, 2800, 1400, 2800, 700};
uint16\_t pink[23] = {700, 700, 700, 2100, 1400, 700, 700, 2800, 700, 1400, 700, 700, 700, 2800, 1400, 1400, 700, 2100, 700, 700, 700, 2100, 700};
Step 5: Initialize Irsend in Setup:
void setup() {
irsend.begin();
}
Step 6: In Loop We Are Going to Put the Following:
void loop() {
irsend.sendRaw(yellow, 21, 38);
delay(200);
irsend.sendRaw(green, 21, 38);
delay(200);
irsend.sendRaw(pink, 23, 38);
delay(200)
irsend.sendRaw(blue, 27, 38);
delay(200)
}
This will cause the wristband to turn yellow, wait 200 ms, then green, wait 200 ms, then pink, wait 200 ms and finally blue to wait 200 ms again before restarting.
Here the important thing is to pass through sendRaw, the name of the color variable, the size of the value, and the frequency at which it operates, in this case at 38kHz.
Well, we can now control the bracelet with the colors we have chosen, now we will synchronize it with the music, and for this we will use the sound sensor KY-038.
This sensor has one analog pin and one digital pin, in addition to the power pins.
After testing it, I honestly have not been able to make use of the data delivered by the analog pin and it seems to be merely referential, and although in the diagram of this project the analog pin is connected to the A0 pin, we can actually leave it disconnected.
Step 7: We Declare Our Pins:
const int microAnalog = A0;
const int microDigital = 16;
Step 8: We Change the Mode to Input Inside the Setup() Function and It Will Look Like This:
void setup() {
irsend.begin();
pinMode(microAnalog, INPUT); // podemos ignorar esta linea
pinMode(microDigital, INPUT);
}
Step 9: And in Loop() We Will Put the Following:
So that every time the sound sensor sends us a HIGH signal (when it detects a sound that exceeds the configured threshold) the signal is sent by IR to turn on the bracelet.
if (digitalRead(microDigital) == HIGH) {
irsend.sendRaw(yellow, 21, 38);
}
delay(200)
Step 10: As We Have Several Colors We Will Do the Following So That They Are Executed Randomly:
void loop() {
int randomNumber = random(1, 4);
if (digitalRead(microDigital) == HIGH) {
if (randomNumber == 1) {
Serial.println("send yellow code");
irsend.sendRaw(yellow, 21, 38);
}
if (randomNumber == 2) {
Serial.println("send green code");
irsend.sendRaw(green, 21, 38);
}
if (randomNumber == 3) {
Serial.println("send pink code");
irsend.sendRaw(pink, 23, 38);
}
else {
Serial.println("send blue code");
irsend.sendRaw(blue, 27, 38);
}
delay(200);
}
}
Step 11: Compile and Load the Sketch in Our Microcontroller
Now, every time the sensor detects a sound and sends a HIGH signal to the microcontroller, an IR signal will be sent to turn on the bracelet with a random color.
Notes:
1) Make sure that the KY-038 sensor is calibrated; otherwise, it will always send a HIGH signal.
You do this by turning the small knob (see yellow arrow) with a flat screwdriver, until the light on the right turns off (see green arrow), this light will only turn on when it detects a sound passing the threshold.
2) As I show in the video, you will have to bring the microphone of the sensor as close as possible to the speaker to better detect the sound.
That's all, I hope you liked it!
If you have any questions or suggestions, I look forward to hearing from you in the comments.
Project repository: https://github.com/drneox/pixmob-music-rhythm