Trying to build a Voicechanger for Cosplay

Hey there, fairly new to arduinos in general.

I'm trying to build a Mic/speaker setup that modulates my voice (maybe even adds a few sound blibs on top of it).

Right now I've got a small breakout-board mic connected to 5V, ground and an analog pin.

On the otherside I have a small LM386 board + a small speaker, the LM386 board is connected to 5V, a digital Pin and ground.

But for whatever reason I can't seem to figure out, what I'm actually doing wrong.

Here's snippet from my code:

//Microphone

const int micPinA = A7;

int micA;
int amplitudeA;

const int baseline = 337;
const int maxAmplitude = 150;

//Speaker

const int speakerPin = 8;


void setup()
{

  Serial.begin(9600);

  pinMode(micPinA, INPUT);
  pinMode(speakerPin, OUTPUT);

//Test Noise
  tone(speakerPin, 200, 2000);

//SD Card stuff

}

void loop()
{


  micA = analogRead(micPinA);
  amplitudeA = abs(micA - baseline);

//Cut down the 10Bit input to 8bit (I saw this online somewhere, but even without it, it wont work)
//Also even if I use either micA or amplitudeA I wont receive any noise from the speaker.
//The test tone from the Setup() Function works tho.
//If I use tone and then AmplitudeA as the frequency I can here a difference while 
//speaking/making any type of noise
  analogWrite(speakerPin, analogRead(micPinA)>>2);


}

Thanks in advance!

BTW I wanna use a microcontroller, because I want to do lots more with it, than just this, control LEDs (depending on the Voice Input) and a few other things. I also want to contain all of it in one system (so microcontroller + parts) and not multiple smaller sets of systems.

Any help is greatly appreciated!

Edit:

I'm basically trying to sample my Voice through a Microphone right now and than outputting that through a speaker.
After that I want to work on modulation of the voice + voice effects.

I'm fairly new to arduinos.
I've used Raspberry PIs for all sorts of stuff, one such use case was this exact project.
I want to move away from Raspberry PIs for this sorta' stuff.

Edit 2:

I'm using a Nano, but I'm not fixed to using a Nano.
I'm not super sure how large the others are, but that shouldn't be an issue inside my helmets. (Hopefully)

I don't think analogRead should be declared as in input.

Neither can I because you did not describe what you are trying to do! Just saying "modulates" tell nothing.

Me neither, but it doesn't matter.
Neither making the low frequency PWM pin an output.

Posting in a section of the forum that specifically asks you not to?
Not good.

he is trying to sample his own voice and output to a pin forgetting how pwm and adc works

Based on the topic I'm sure we can all get a general sense for what he's trying to do.

Or maybe needs some help learning and hasn't forgotten anything yet?

What exactly is happening that shouldn't be or what isn't happening that should be?

I think you need to look at measuring the incoming frequency, not just the amplitude and output that as a tone. Constantly changing tone to match the incoming frequency from your voice.

1 Like

What should be happening right now is that I'm just sampling the mic, in this case my voice, and outputting it to the speaker/the LM386.

I haven't played around much with arduinos.
I've used Rapsberry PIs for most of my previous stuff.

So yea, some pointers towards how to sample/output voice would be nice.

Alright, is there any reason to not declare it as an input?

Firstly I'm just trying to sample and output my voice.
Afterwards I want to modulate it, depending on the use case.

That could mean, for my current cosplays Clone Trooper Radio Voices / Radio Sounds + Voice.
Or anything else really.

In that case you need to convert the digital sample back to an analog voltage,

Any pointers for doing that sorta stuff?

Should i sample an analog or digital value from my mic?

Is the Value I should be giving to the speaker/lm386 analog or digital?
Currently I'm using Digital, which works for Tones and an TI-99 Voice example I found online.

I've pondered what you're trying to do but haven't actually tried it. Sorry.

You're using it with analogRead.
What else could it be?

Similarly (but oppositely), with analogWrite.

My understanding, which could be wrong, is that some boards configure themselves differently depending on what they're being used for. Declaring it as an input could turn on a circuit that might effect the analogRead function. Maybe.

Most voice changers are totally analog.

So analog In and output?
Is that correct?

Did you look at this device? after an internet search?

No i did not find that, thanks, I'll look into that.

After reading through this article, yes this is kinda what I want.
But not quite.
As I've stated in my OG post, I want to use an arduino for this. Multiple reasons why, just take it as is please.

Thanks for the answer tho.