D0 is input than receive audio signal
Reading an audio frequency on a digital pin doesn't make sense. Even if it did, you don't get frequency from one reading. So, you can't compare 5 consecutive readings, to see if you got that collection of values.