Go Down

Topic: Answered: LM393 sound detector won't wake up Pro Mini from sleep  (Read 449 times) previous topic - next topic

skorekaj

Hi All, I'm a noob trying to get a sound detection project off the ground, help understanding this is much appreciated as this is driving me mad.

Problem:
Im putting the Arduino to sleep but cannot get it to wake up when a sound is detected and turn on the onboard LED for 2 seconds.

Setup:
i have got a Pro Mini and the "Sound Detection Sensor Module LM393" :
http://www.ebay.co.uk/itm/111513483333?_trksid=p2060778.m2749.l2648&ssPageName=STRK%3AMEBIDX%3AIT

The Signal pin is attached to A0 (grd and Vcc also connected) and i can see that the sound detection is appearing as the led lights up however i cannot get the interrupt to fire.
If i enable serial output , i can see that the A0 pin is sensing 1023 until a sound triggers the module and the led comes on and the signal changes to 23 or there abouts briefly.

This code:

#include <avr/sleep.h>
 volatile int val = 0;

void setup() {
  pinMode(13, OUTPUT);
  pinMode(A0, INPUT);

}
void loop() {
  if(val == 1){
    digitalWrite(13,HIGH);
    delay(2000);
    digitalWrite(13,LOW);
    val = 0;
  }
  attachInterrupt(0, isr, LOW);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  sleep_cpu();
}
void isr()
{
  sleep_disable();
  detachInterrupt(0);
  val = 1;
}


i have tried all the interrupts in as well (rising falling and so on) but to no avail.

Cheers, SkoreKaj

skorekaj

And the answer is: (I'm an idiot) i had the signal wire from the lm393 connected to A0 which is NOT pin2 interrupt 0.
Once switched around, it works like a champ :) !!!


DOOOOH !!!!

onesky

hey can u explain better how u made it LM393 sound sensor works with arduino? i cant :(

Go Up