Introduction: Led Mask With Voice Control
(Created for school project A.V.)
Motivation
In popular media we see a lot of different interpretations of the future of our clothing and accessories. One of these are the sleek and futuristic clothing designs from sci fi movies like Bladerunner. Another one is the crazy headgear and cybernetics from media like Cyberpunk 2077.
From the second one i took the inspiration for my project.
Personally i'm interested in the possibility of clothing and accessories being an extension of the user that wears it. With this in mind, i wanted to show the users emotions by the volume of their voice. Ofcourse facial recognition would have been a better option but i'm not familiar with that kind of technology.
How does it work
When the user speaks into the microphone on the mask it measures the volume. When the sound detection module detects sound above a certain threshold than the talking state is activated(with animations) and an appropriate color is shown(normal being happy green and loud being angry red). The last emotion detected will stay on the mask until the users speaks again or keeps quiet for a certain amount of time. If the user stays quiet than the mask enters the sad state until the user speaks again.
Supplies
- 5x Female to male jumper wires
- 6x Male to male jumper wires
- 4x Led connecters (optional)
- 1x Resistor
- 1x Sound Detection Sensor Module
- 1x USB cable (optional)
- 1x powerbank (optional power supply)
- 1x Roll of ductape (or other type adhesive)
- 1x Sleeping Mask with hardcover
- 1x Breadboard (or pin plate)
- 1x Hip pouch
- 1x 50 to 50 cm cardboard
- 1x 30 to 30cm black cloth
- 1x WS2812B Digitale 5050 RGB LED Strip (27x leds needed)
Step 1: Design
During the first design stage of my led mask i tried to make a drawing of the concept as it was in my head. As you can see in the sketch above i tried to visualize the most important aspects of the mask itself.
These were: a sound module, a sleepmask with face plate, a storage for the arduino with power supply and a bunch of RGB leds to simulate facial expressions.
Now that i have the important aspects defined, i needed the required components to actually start this project.
Admittley there were some bumbs along the road as i didn't have a lot of experience with Arduino yet.
Step 2: Iterations
Mistakes were made (but better ideas emerged)
When i first started developing my led mask i had the idea to cover my entire face with a 16x16 led RGB matrix. This would definetly have enough leds to create the facial expressions i wanted.
However i quickly found the negatives from this approach. The first being that the user could not see a thing because of the massive matrix covering his/her sight. The second and biggest problem being power supply. A 16x16 led RGB matrix held a current of 60mA per led. If i were to use this, a normal battery would drain within minutes and since the mask has to be portable, a switching power supply was not an option for me.
There for i decided to cut a individually addressable RGB LED strip for the required amount and place them in such a way so that i could create facial expressions. This could also solve the problem of sight, since i could cut holes into the carboard at places that didn't have a led on them.
The mask without electrical components
For the naked mask carve a oval/ face shaped piece of cardboard of about 22x25 cm. Cut two square holes for where the users eyes would be(make sure these have atleast 10 cm of space in between). create two slight folds towards the back of the mask. One in the middle and two near the sides. Do this so that the cardboard can bend more easily.
Cut two large holes in the sleeping mask and use adhesive to paste it to the back of the craboard.
Led strips attached to front.
Take your led strip and prepare to seperate these carefully so you can place the shorter strips at convienient places. You need to have 2x strips of 3 RGB LEDS and 3x strips of 7 RGB leds. Place the two strips of 3 near the eyes at the middle and the three strips of 7 in rows at the bottom for were the mouth would be.
Connect the strips in the order shown in the schematic image above. Make sure to connect 5v to 5v, ground to ground and DO to DIN. You can either solder a cable between these points or use led connecters like i did.
Sound Sensor Module
This one is a bit easier, but you might need to adjust the potentiometer later when the code is uploaded until the correct sensitivity is achieved. You can use adhesive to paste the module at the back of the mask (where the users mouth would be). Make sure that the microphone is not covered.
After these steps are completed. Pul the cloth over the front of the mask and use adhesive. Cut all the excess cloth at the back of the mask.
Step 3: Circuit
Step 4: Power Supply
Power supply
There are multiple ways to power the arduino and led strips. In my case i used a powerbank and a cut USB cable. You could either connect the cut usb cable's power cables to female to male jumperwires or you could directly solder these to a pin plate(or put them in a breadboard). In my case i did a combination of both. I soldered Female to male jumper wires onto a pin plate and conected these to the USB cable.
Step 5: Code
* Make sure to install the Adafruit Neopixel library
Most of the code is comented but i will give a short summary of whats happening:
The mask holds three states: happyState, SadState and angryState. This will be updated every loop. The running code will loop every 0.2 seconds
First a call will be made to the setMaskState() function. Here it will measure the sound input value. when sound is above sound_min, it will set Mask_state to either happy or angry state state and set is_talking to true. if sound detection measured value is lower than sound_min it wil set is_talking to false and countdown to sadState. If timer is under 0 than sadState will be activated and will stay so until the measured value goes above the sound_min.
When is_talking is true, switch between open and closed mouth with the given rgb colorof the current state.
The eyes will alwasy be displayed with the given rgb color of the current state.
When another loop is started, all the leds will be turned of and await their new assignment.
<em>#include <Adafruit_NeoPixel.h>// Microphone variablesint num_Measure = 128 ; // Set the number of measurements int MIC_OUT_PIN = A0; // pin connected to pin O module sound sensor long Sound_signal; // Store the value read Sound Sensor long sum = 0 ; // Store the total value of n measurements long level = 0 ; // Store the average valueint sad_time = 50; // time until mask enters sad stateint timer; // time counterint sound_min = 150; // min sound volume for detection (happy)int sound_medium = 680; // med sound volume for detection (Angry)// Mask RGB variablesint PIN = 6; // Pin for signal neopixelsint N_LEDS = 27; // Number of leds on maskint mask_state = 2; // 1 = happy; 2 = angry; 3 = sad;bool is_talking = false;bool lips_closed = false;uint32_t rgb_red;uint32_t rgb_blue;uint32_t rgb_green;Adafruit_NeoPixel pixels = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);void setup() { pinMode (MIC_OUT_PIN, INPUT); // Set the signal pin as input Serial.begin(9600); pixels.begin(); // Initialize Neopixel library timer = sad_time; rgb_red = pixels.Color(255,0,0); rgb_blue = pixels.Color(0,255,255); rgb_green = pixels.Color(0,255,0);}void loop() { setMaskState(); turnOffPixels(); pixels.show(); switch(mask_state) { case 1: sadState(); break; case 2: happyState(); break; case 3: angryState(); break; } pixels.show(); delay(200);}// Measure the sound value. if sound is above sound_min, set Mask_state to the corresponding state and set is_talking to true.// if sound detection is under sound_min set is_talking to false and countdown to sadState. void setMaskState() { sum = 0; // Reset the sum of the measurement values // Performs 128 signal readings for ( int i = 0 ; i <num_Measure; i ++) { Sound_signal = analogRead (MIC_OUT_PIN); sum = sum + Sound_signal; } level = sum / num_Measure; // Calculate the average value Serial.print("Sound Level: "); Serial.print (level-40); if(level-40<sound_min) { Serial.println(" min"); if (timer <= 0) { mask_state = 1; } else { timer--; } is_talking = false; return; } if(level-40>sound_min && level-40<sound_medium) { Serial.println(" medium sound"); timer = sad_time; is_talking = true; mask_state = 2; // happy state } if(level-40>sound_medium) { Serial.println(" High sound"); timer = sad_time; is_talking = true; mask_state = 3; // angry state }}void displayEyes(uint32_t rgb) { for (int i = 0; i < 6; i++) { pixels.setPixelColor(i, rgb); }}// When is_talking is true, switch between open and closed mouth with the given rgb colorvoid talkState(uint32_t rgb) { if(lips_closed) { for (int i = 7; i < 12; i++) { pixels.setPixelColor(i, rgb); } pixels.setPixelColor(14, rgb); pixels.setPixelColor(18, rgb); for (int i = 21; i < 26; i++) { pixels.setPixelColor(i, rgb); } lips_closed = false; } else { for (int i = 13; i < 20; i++) { pixels.setPixelColor(i, rgb); } lips_closed = true; } }void happyState() { displayEyes(rgb_green); if(is_talking) { talkState(rgb_green); } else { pixels.setPixelColor(6, rgb_green); pixels.setPixelColor(12, rgb_green); pixels.setPixelColor(14, rgb_green); pixels.setPixelColor(18, rgb_green); for (int i = 22; i < 25; i++) { pixels.setPixelColor(i, rgb_green); } }}void angryState() { displayEyes(rgb_red); if(is_talking) { talkState(rgb_red); } else { for (int i = 13; i < 20; i++) { pixels.setPixelColor(i, rgb_red); } }}void sadState() { displayEyes(rgb_blue); if(is_talking) { talkState(rgb_blue); } else { for (int i = 8; i < 11; i++) { pixels.setPixelColor(i, rgb_blue); } pixels.setPixelColor(14, rgb_blue); pixels.setPixelColor(18, rgb_blue); pixels.setPixelColor(20, rgb_blue); pixels.setPixelColor(26, rgb_blue); }}void turnOffPixels() { for (int i = 0; i < N_LEDS; i++) { pixels.setPixelColor(i, 0); }}<br></em>
Step 6: Reflection
I definitely had some problems in the beginning. This came from the fact that i didn't do enough research en power current and the right RGB leds for my project.
Despite these problems i can see (as shown in iterations) that some better idea's emerged. Now the user can actualy see through the mask and in combination with the powerbank, my mask could last up to atleast 16 hours.
I'm not a very crafty person but i'm still statisfied with the look of the mask. In the future i could maybe use a better cable leading to the hip pouch.
As a whole i'm pretty satisfied with how this project turned out though. I also got some positive reaction from my classmates and teachers some i'm pretty confident my project was a succes
Thanks for reading :)