pulse detector code with all dependencies