Adding code to control Edge Detection

will need to fix sensor readings. it seems they're the other way round!