Analog comparators throw an output high or low based on the comparison of two voltages. Normally you’d use an OpAmp or Comparator IC for this, but here I’m testing the essential concept realised with discrete transistors.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub
Here’s a trace of the output (red) resulting from the comparison of input (yellow) and reference (blue) voltages..