Remove the duration-based oscilloscope mode; just read 256 times, that's enough for a reasonable plot. Remove the analog read that takes the mode of several readings - it was typically returning the upper or lower readings, not anything useful - so just use the mean.
Use constants for the forward and reverse detector analogue input pins; allow the pin measured by the oscilloscope mode to be specified with E (reverse) and F (forward) commands.