Improved PowerDetector and added P5 example code