Go Down

Topic: Trouble with analogRead for audio volume level (Read 1 time) previous topic - next topic



Apologies, newbie here. I'm having trouble implementing analogRead. Here's a chunk of code:

Code: [Select]
  while (wave.isplaying) {
     volume = 0;
      for (i=0; i<8; i++)
        v2 = analogRead(1);

   if (v2 > 440)    //440
           pulseWidth = 1800;  //1800
           mouthchange = 1;
           pulseWidth = 800;  //800
           mouthchange = 1;

  digitalWrite(servoPin, HIGH);   // start the pulse
  delayMicroseconds(pulseWidth);  // pulse width
  digitalWrite(servoPin, LOW);    // stop the pulse

I've soldered a link of wire from R7 to Analog In 1 to (hopefully) read the volume in as a voltage change. I'm attempting to follow the following instructable:http://www.instructables.com/id/Talking-Arduino-Halloween-Skeleton/?ALLSTEPS

Any ideas what I'm doing wrong? I've isolated that all the hardware is good - uploaded the sample servo sweep sketch and the servo moves as expected.

Thanks, in advance, for your time.



It's hard to say, have you measure a voltage at analog pin1 with DMM?
If don't have one, you can insert in the code a couple debug lines, Serial.Print(xxx), and print out v2 value just after "for" loop.


Thanks for the reply.

I have metered it at approx. 1.2vdc steady, which is not at all what I would expect for this work. The tutorial implies this voltage would change with the audio level. Perhaps another forum is appropriate.

Thanks for this suggestion.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131