I connected the sensor with an analog pin (A0) but I was able to read the "edge" out with "digitalRead", how is that possible?
The analog pins, 0 to 5, can be used as digital pins, with different number (14 to 19 on the 328-based Arduinos). The A0 string is #defined to have the correct value (14 for a 328-based Arduino, 54 on a Mega) on any Arduino.