110 AC wireless doorbell output

So I am working on using the speaker output from a wireless doorbell to blink and LED... and eventually ring a rotary phone. So, I figure I should elaborate on the 110AC vs a battery one. Basically it was what was already installed in the house and I have 110AC coming into my project as a power supply to create a signal to ring a old rotary dial phone. Anyways, it seems the speaker output has some influance from the AC signal as when I read the analog output on A0 it looks something like this:

0 0 159 144 0 0 158 132 0 0 158 138 0 0 158 141 0 0 158 142 0 0 158

When I depress the ring button, it gives the following values:

14 14 11 13 14 13 11 12 14 14 11 13 14 13 11 12 13 13 11

I figured trying to read a value beween 10-20 would give me the output I was looking for, but no matter what I do, the LED seems to blink. I figure this s because I'm a pretty terrible programmer and cant isolate the 'ring'.

Thanks!

//Ring



int ledPin = 3;   // LED connected to digital pin 13
int potPin = A0;    // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 5000;

void setup() {
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  pinMode(potPin, INPUT_PULLUP); // use Pull Up resistor on A0
  Serial.begin(9600);           // open serial port at 9600 baud

}

void loop() {
  val = analogRead(potPin);
  //Serial.println(val, DEC);
  if (val = 1000000) {              // if the circuit is completed
  // (for me, it generally drops from 1023 to ~ 15 when 'ringing')
    if (millis()-time > debounce) {
      //Serial.println("ON");
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(500);                   // ...wait for half a second
      digitalWrite(ledPin, LOW);    // and turns the LED off
      time = millis();
      
    }
  }
}

could it be that the output goes to ground when active?

a "flag" might be set to the max value read by the analogRead and would be checked/reset periodically. the code would recognize an active condition if the flag remains a low value between checks

this is probably not what you intended (need to use "==")

if (val = 1000000) {

Would have been nice to know which type of MCU/Arduino you are using…

  1. 1000000 is out of range for type “int”.
  2. Data type for storing “millis()” should be unsigned.
  3. 5 seconds for debouncing?
  4. Since you are pulling up the input pin, it must go low on change.

Please post a wiring diagram.