LED mask help (total noob)

Edit: got it working seems the batch of mics I got where DOA.

So this is my first project using anything Arduino so I am a total noob at this.
I am trying to make a voice-activated LED mask but I can’t seem to get the mic to work right. I’m not sure if I have something wrong with the code as it is a precompiled code from someone else. or if I just am not wiring it upright.

This is the items I have

Adafruit Flora (Amazon Link)
GY-MAX4466 Electret Microphone Amplifier (Amazon Link)
kuman for Arduino 8x8 RGB LED (Amazon Link)

and this is the code I am using

#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include <gamma.h>

#define lengthof(A) ((sizeof((A))/sizeof((A)[0])))

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,0,0,0,0,0,0},
    {6,6,6,6,6,6,6,6},
    {6,6,6,6,6,6,6,6},
    {0,0,0,0,0,0,0,0},
    {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,6,6,6,6,0,0},
    {0,6,0,0,0,0,6,0},
    {6,0,0,0,0,0,0,6},
    {6,0,0,0,0,0,0,6},
    {6,0,0,0,0,0,0,6},
    {6,0,0,0,0,0,0,6},
    {0,6,0,0,0,0,6,0},
    {0,0,6,6,6,6,0,0}
};

const PROGMEM uint8_t mouth_3[8][8] = {
    {0,0,0,0,0,0,0,0},
    {0,0,6,6,6,6,0,0},
    {0,6,0,0,0,0,6,0},
    {6,0,0,0,0,0,0,6},
    {6,0,0,0,0,0,0,6},
    {0,6,0,0,0,0,6,0},
    {0,0,6,6,6,6,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,6,6,6,6,6,6,0},
    {6,0,0,0,0,0,0,6},
    {6,0,0,0,0,0,0,6},
    {0,6,6,6,6,6,6,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,6,6,0,0,0},
    {6,6,6,0,0,6,6,6},
    {6,6,6,0,0,6,6,6},
    {0,0,0,6,6,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},
    {6,0,0,0,0,0,0,6},
    {6,6,0,0,0,0,6,6},
    {0,6,6,6,6,6,6,0},
    {0,0,6,6,6,6,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0}
};

uint16_t palette[8] = {};
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, 6,
  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 );
            matrix.drawPixel(x, y, palette[index]); 
        }
    }

    matrix.show();
}

int pop_detection = 0;
bool smiling = false;
unsigned long smiletimer = 0;
unsigned long last_face = 0;

void setup() {
    matrix.begin();

    palette[0] = matrix.Color(0,0,0);
    palette[1] = matrix.Color(255,0,0);
    palette[2] = matrix.Color(0,255,0);
    palette[3] = matrix.Color(0,0,255);
    palette[4] = matrix.Color(0,255,255);
    palette[5] = matrix.Color(255,0,255);
    palette[6] = matrix.Color(255,255,0);
    palette[7] = matrix.Color(255,255,255);

    Serial.begin(9600);
}

float vol = 0;
const uint16_t samples = 128;

void loop() {
    float nvol = 0;
    int previous_peak = -1;
    
    for (int i = 0; i<samples; i++){
        auto analog = analogRead(9);
        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 > 2) {
            smiling = false;
            last_face = millis();
        }
    } else {
        if(pop_detection > 0 && pop_detection <= 2) {
            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){
        drawImage(mouth_1);
    } else if(vol < 350){
        drawImage(mouth_2);
    } else if(vol < 450){
        drawImage(mouth_3);
    } else {
        drawImage(mouth_4);
    }
}

Start with the most simple possible sketch to check whether your microphone is working:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(9));
}

Upload that to your Flora and then open Tools > Serial Monitor. You should now see a line of numbers quickly scrolling down the Serial Monitor output window. The range of the numbers is 0-1023. When there is complete silence, the numbers should be around 500. If you make a loud noise, you should see numbers that are jumping around between values closer to 0 and 1023.

When you do this, do you see the behavior I described above?

pert:
Start with the most simple possible sketch to check whether your microphone is working:

void setup() {

Serial.begin(9600);
}

void loop() {
 Serial.println(analogRead(9));
}



Upload that to your Flora and then open **Tools > Serial Monitor**. You should now see a line of numbers quickly scrolling down the Serial Monitor output window. The range of the numbers is 0-1023. When there is complete silence, the numbers should be around 500. If you make a loud noise, you should see numbers that are jumping around between values closer to 0 and 1023.

When you do this, do you see the behavior I described above?

The numbers where not jumping around like they should when making a loud noise. So it seems I do not have it connected right.
gnd going to gnd
vcc going to 3.3v
out going to #9 (A9,D9)

Your millis() timing is wrong. You should never create future timestamps.

sabejithepirate:
The numbers where not jumping around like they should when making a loud noise.

What are the numbers you're seeing?

sabejithepirate:
So it seems I do not have it connected right.
gnd going to gnd
vss going to 3.3v
out going to #9 (A9,D9)

That looks fine to me.

Vss is terminology for a negative supply. You must mean Vcc.

pert:
What are the numbers you're seeing?
That looks fine to me.

between 0-200 or so no change when making a sound or having no sound.
I have another mic I can try but it has 4 pins D0 , + , G , A0

aarg:
Vss is terminology for a negative supply. You must mean Vcc.

Yea my bad meant Vcc edited it to be correct.

Did you try adjusting the gain pot?

aarg:
Did you try adjusting the gain pot?

Yea I did, I even tried setting it to be super sensitive and still no changes in the numbers.

Ok before I end up being a complete fool and wasting so much time having it powered from just the USB is fine right? or should I have it powered with a battery while testing too?

USB power should be fine.

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks... Tom... :slight_smile:

I managed to get it working. seems the batch of mics I got where DOA.