voice activated LED facemask connection instructions
Precautions:When making a voice-activated lamp mask, please be careful during the welding of the circuit, so as not to burn yourskin by the welding machine! Please connect the circuit correctly and choose agood charging treasure. Short circuit and poor current input of the circuit maycause accidents! The voice-activated light mask is to be attached to the face, so the choice of mask fabric is very important, please choose fire-resistantfabric! Finally, please ask the younger children to make the productionaccompanied by an adult.
Tools Needed:Solder
Soldering iron
Fabric Glue or a Sewing Kit
Safety goggies
Tape
snips
Optional Useful StuffA heat shrink (electrical tape can make duein a pinch, but the heat shrink is nice)
A digital multimeter (for ensuring yourconnections are correct and your electronics work)
A soldering mat
Arduino Nano
The PartsLed matrix 8x8 WS2812B
Microphone max4466
Arduino Nano
330Ω resistor
24 Gauge wire
Heat shrink
5V power bank
KCD1 Switch
Physical circuit diagramLed matrix 8x8 WS2812B DIN pin------------330Ω resistor
330Ω resistor------------Arduino Nano D6 Pin
max4466 microphone VCCpin-------------Arduino Nano 5V Pin
max4466 microphone GNDpin-------------Arduino Nano GND Pin
max4466 microphoneOUT pin-------------Arduino Nano A7 Pin
Led matrix 8x8 WS2812B 5V pin------------ Arduino Nano VIN Pin
Led matrix 8x8 WS2812B GND pin------------ Arduino Nano GND pin
KCD1 switch------------ Arduino Nano D12 pin
Arduino Nano GNDpin------------ KCD1 switch
Production
1. Install Library file: Open"Tools"-"Library Manager" in the Arduino developmentsoftware, then search for Adafruit_NeoPixel, Adafruit_NeoMatrix, Adafruit_GFX_Library, and then install these three libraries
2. Select the development board asArduino Nano, this is to choose the right.
3. Select the processor asATmega328P(Old Bootloader), this is to choose the right.
4. Then select the port, this portshould be the same as what you see in the device manager, so that you can burnthe code into the development board.
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include <gamma.h>
#define lengthof(A) ((sizeof((A))/sizeof((A)[0])))
#define button 12
int oldstate=HIGH;
const PROGMEM uint8_t mouth_0[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,6,6,6,6,0,0},
{0,6,6,6,6,6,6,0},
{6,6,0,0,0,0,6,6},
{6,0,0,0,0,0,0,6},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_4[8][8] = {
{0,0,7,7,7,7,0,0},
{0,7,0,0,0,0,7,0},
{7,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,7},
{0,7,0,0,0,0,7,0},
{0,0,7,7,7,7,0,0}
};
const PROGMEM uint8_t mouth_3[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,7,7,7,7,0,0},
{0,7,0,0,0,0,7,0},
{7,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,7},
{0,7,0,0,0,0,7,0},
{0,0,7,7,7,7,0,0},
{0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_2[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,7,7,7,7,7,7,0},
{7,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,7},
{0,7,7,7,7,7,7,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_1[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,7,7,0,0,0},
{7,7,7,0,0,7,7,7},
{7,7,7,0,0,7,7,7},
{0,0,0,7,7,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_smile[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{2,0,0,0,0,0,0,2},
{2,2,0,0,0,0,2,2},
{0,2,2,2,2,2,2,0},
{0,0,2,2,2,2,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t off_set[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}
};
uint16_t palette[8] = {};
Adafruit_NeoMatrix matrix1 = Adafruit_NeoMatrix(8, 8, 6,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrix2 = Adafruit_NeoMatrix(8, 8, 7,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrix3 = Adafruit_NeoMatrix(8, 8, 2,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrix4 = Adafruit_NeoMatrix(8, 8, 0,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
void drawImage(short image_addr){
for(int x = 0; x<8; x++){
for(int y = 0; y<8; y++){
uint8_t index = pgm_read_byte(image_addr+x+y*8);
matrix1.drawPixel(x, y, palette[index]);
matrix2.drawPixel(x, y, palette[index]);
matrix3.drawPixel(x, y, palette[index]);
matrix4.drawPixel(x, y, palette[index]);
}
}
matrix1.show();
matrix2.show();
matrix3.show();
matrix4.show();
}
int pop_detection = 0;
bool smiling = false;
unsigned long smiletimer = 0;
unsigned long last_face = 0;
float vol = 0;
const uint16_t samples = 128;
void setup() {
Serial.begin(9600);
matrix1.begin();
matrix2.begin();
matrix3.begin();
matrix4.begin();
palette[0] = matrix4.Color(0,0,0); //No color
// palette[1] = matrix.Color(0,0,255); //blue
palette[2] = matrix3.Color(255,0,255); //purple
// palette[3] = matrix.Color(0,255,0); //green
// palette[4] = matrix.Color(255,255,255); //white
// palette[5] = matrix.Color(255,0,0); //red
palette[6] = matrix1.Color(0,255,255); //yellow
palette[7] = matrix2.Color(255,255,0); //cyan
pinMode(button,INPUT_PULLUP);
}
void loop() {
int newstate=digitalRead(button);
if(newstate == LOW){
float nvol = 0;
int previous_peak = -1;
for (int i = 0; i<samples; i++){
auto analog = analogRead(A7);
auto micline = abs(analog - 512);
nvol = max(micline, nvol);
}
vol = (nvol + 1.0*vol)/2.0;
if(nvol > 200){
pop_detection += 1;
if(pop_detection > 5) {
smiling = false;
last_face = millis();
}
} else {
if(pop_detection > 0 && pop_detection <= 5) {
if(millis() > last_face + 500){
smiling = true;
smiletimer = millis() + 2000;
}
}
pop_detection = 0;
}
if(millis() > smiletimer)
smiling = false;
if(smiling){
drawImage(mouth_smile);
} else if(vol < 200){
drawImage(mouth_0);
} else if(vol < 250 && vol > 200){
drawImage(mouth_1);
} else if(vol < 350 && vol > 250){
drawImage(mouth_2);
} else if(vol < 450 && vol > 350){
drawImage(mouth_3);
} else {
drawImage(mouth_4);
}
}
else
{
drawImage(off_set);
}
}
Comments
Please log in or sign up to comment.